X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=httemplate%2Felements%2Fcalendar.js;h=80c6d1f6799d72b3e0622068d3d2f4730700d541;hp=f5c74f608dd2dd0b0608fcb4fff64d6ca3d81505;hb=b71b1576c68bc40ad26592b354feace37a029f0e;hpb=9509e5bfb7f9331303153cac24d7bfecbe2ea9f1 diff --git a/httemplate/elements/calendar.js b/httemplate/elements/calendar.js index f5c74f608..80c6d1f67 100644 --- a/httemplate/elements/calendar.js +++ b/httemplate/elements/calendar.js @@ -1635,6 +1635,17 @@ Date.parseDate = function(str, fmt) { case "%M": min = parseInt(a[i], 10); break; + + case "%r": + hr = parseInt(a[i], 10); + min = parseInt(a[++i], 10); + var sec = parseInt(a[++i], 10); + if (/pm/i.test(a[++i]) && hr < 12) + hr += 12; + else if (/am/i.test(a[i]) && hr >= 12) + hr -= 12; + break; + } } if (isNaN(y)) y = today.getFullYear(); @@ -1759,7 +1770,13 @@ Date.prototype.print = function (str) { s["%n"] = "\n"; // a newline character s["%p"] = pm ? "PM" : "AM"; s["%P"] = pm ? "pm" : "am"; - // FIXME: %r : the time in am/pm notation %I:%M:%S %p + + // %r : the time in am/pm notation %I:%M:%S %p + s["%r"] = ( (ir < 10) ? ("0" + ir ) : ir ) + ':' + + ( (min < 10) ? ("0" + min) : min ) + ':' + + ( (sec < 10) ? ("0" + sec) : sec ) + ' ' + + (pm ? "PM" : "AM" ); + // FIXME: %R : the time in 24-hour notation %H:%M s["%s"] = Math.floor(this.getTime() / 1000); s["%S"] = (sec < 10) ? ("0" + sec) : sec; // seconds, range 00 to 59 @@ -1790,6 +1807,7 @@ Date.prototype.print = function (str) { return str; }; +if ( !Date.prototype.__msh_oldSetFullYear ) { Date.prototype.__msh_oldSetFullYear = Date.prototype.setFullYear; Date.prototype.setFullYear = function(y) { var d = new Date(this); @@ -1798,6 +1816,7 @@ Date.prototype.setFullYear = function(y) { this.setDate(28); this.__msh_oldSetFullYear(y); }; +} // END: DATE OBJECT PATCHES