0
@@ -4,27 +4,29 @@ Object.extend(Date.prototype, {
0
* Example: new Date().strftime("%A %I:%M %p")
0
strftime: function(format) {
0
- var day = this.getDay(), month = this.getMonth();
0
- var hours = this.getHours(), minutes = this.getMinutes();
0
+ var day = this.getUTCDay(), month = this.getUTCMonth();
0
+ var hours = this.getUTCHours(), minutes = this.getUTCMinutes();
0
function pad(num) { return num.toPaddedString(2); };
0
- return format.gsub(/\%([aAbBcdHImMpSwyY])/, function(part) {
0
+ return format.gsub(/\%([aAbBcdDHiImMpSwyY])/, function(part) {
0
case 'a': return $w("Sun Mon Tue Wed Thu Fri Sat")[day]; break;
0
case 'A': return $w("Sunday Monday Tuesday Wednesday Thursday Friday Saturday")[day]; break;
0
case 'b': return $w("Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec")[month]; break;
0
case 'B': return $w("January February March April May June July August September October November December")[month]; break;
0
case 'c': return this.toString(); break;
0
- case 'd': return pad(this.getDate()); break;
0
+ case 'd': return this.getUTCDate(); break;
0
+ case 'D': return pad(this.getUTCDate()); break;
0
case 'H': return pad(hours); break;
0
- case 'I': return pad((hours + 12) % 12); break;
0
+ case 'i': return (hours === 12 || hours === 0) ? 12 : (hours + 12) % 12; break;
0
+ case 'I': return pad((hours === 12 || hours === 0) ? 12 : (hours + 12) % 12); break;
0
case 'm': return pad(month + 1); break;
0
case 'M': return pad(minutes); break;
0
- case 'p': return hours > 12 ? 'PM' : 'AM'; break;
0
- case 'S': return pad(this.getSeconds()); break;
0
+ case 'p': return hours > 11 ? 'PM' : 'AM'; break;
0
+ case 'S': return pad(this.getUTCSeconds()); break;
0
case 'w': return day; break;
0
- case 'y': return pad(this.getFullYear() % 100); break;
0
- case 'Y': return this.getFullYear().toString(); break;
0
+ case 'y': return pad(this.getUTCFullYear() % 100); break;
0
+ case 'Y': return this.getUTCFullYear().toString(); break;
Comments
No one has commented yet.