MartinBudden
2009-11-05 06:30:27 -0800 (Thu, 05 Nov 2009)
43
Date format fixes, tickets 667, 668 and 671
---------------
U Trunk/core/js/Dates.js
---------------
Modified: Trunk/core/js/Dates.js
===================================================================
--- Trunk/core/js/Dates.js 2009-11-05 14:10:50 UTC (rev 11187)
+++ Trunk/core/js/Dates.js 2009-11-05 14:30:27 UTC (rev 11188)
@@ -83,18 +83,26 @@
// Convert a date to UTC YYYYMMDD.HHMMSSMMM string format
Date.prototype.convertToYYYYMMDDHHMMSSMMM = function()
{
- return this.getUTCFullYear() + String.zeroPad(this.getUTCMonth()+1,2) + String.zeroPad(this.getUTCDate(),2) + "." + String.zeroPad(this.getUTCHours(),2) + String.zeroPad(this.getUTCMinutes(),2) + String.zeroPad(this.getUTCSeconds(),2) + String.zeroPad(this.getUTCMilliseconds(),4);
+ return this.getUTCFullYear() + String.zeroPad(this.getUTCMonth()+1,2) + String.zeroPad(this.getUTCDate(),2) + "." + String.zeroPad(this.getUTCHours(),2) + String.zeroPad(this.getUTCMinutes(),2) + String.zeroPad(this.getUTCSeconds(),2) + String.zeroPad(this.getUTCMilliseconds(),3) +"0";
};
// Static method to create a date from a UTC YYYYMMDDHHMM format string
Date.convertFromYYYYMMDDHHMM = function(d)
{
- var hh = d.substr(8,2) || "00";
- var mm = d.substr(10,2) || "00";
+ d = d?d.replace(/[^0-9]/g, ""):"";
+ return Date.convertFromYYYYMMDDHHMMSSMMM(d.substr(0,12));
+};
+
+// Static method to create a date from a UTC YYYYMMDDHHMMSSMMM format string
+Date.convertFromYYYYMMDDHHMMSSMMM = function(d)
+{
+ d = d ? d.replace(/[^0-9]/g, "") : "";
return new Date(Date.UTC(parseInt(d.substr(0,4),10),
parseInt(d.substr(4,2),10)-1,
parseInt(d.substr(6,2),10),
- parseInt(hh,10),
- parseInt(mm,10),0,0));
+ parseInt(d.substr(8,2)||"00",10),
+ parseInt(d.substr(10,2)||"00",10),
+ parseInt(d.substr(12,2)||"00",10),
+ parseInt(d.substr(14,3)||"000",10)));
};