prototype: Date#toJSON now returns times in UTC for better compatibility with json.js. Closes #9332.
This commit is contained in:
parent
8cf1f895f7
commit
4b1fb7e03a
@ -1,5 +1,7 @@
|
||||
*SVN*
|
||||
|
||||
* Date#toJSON now returns times in UTC for better compatibility with json.js. Closes #9332. [Tobie Langel]
|
||||
|
||||
* Ensure document._getElementsByXPath extends the elements it returns; fixes $$ not returning extended elements in Opera 9.2. Closes #8843. [jdalton]
|
||||
|
||||
* Update Prototype.Browser.MobileSafari for iPod touch compatibility. [sam]
|
||||
|
12
src/base.js
12
src/base.js
@ -197,12 +197,12 @@ Object.extend(Function.prototype, {
|
||||
Function.prototype.defer = Function.prototype.delay.curry(0.01);
|
||||
|
||||
Date.prototype.toJSON = function() {
|
||||
return '"' + this.getFullYear() + '-' +
|
||||
(this.getMonth() + 1).toPaddedString(2) + '-' +
|
||||
this.getDate().toPaddedString(2) + 'T' +
|
||||
this.getHours().toPaddedString(2) + ':' +
|
||||
this.getMinutes().toPaddedString(2) + ':' +
|
||||
this.getSeconds().toPaddedString(2) + '"';
|
||||
return '"' + this.getUTCFullYear() + '-' +
|
||||
(this.getUTCMonth() + 1).toPaddedString(2) + '-' +
|
||||
this.getUTCDate().toPaddedString(2) + 'T' +
|
||||
this.getUTCHours().toPaddedString(2) + ':' +
|
||||
this.getUTCMinutes().toPaddedString(2) + ':' +
|
||||
this.getUTCSeconds().toPaddedString(2) + 'Z"';
|
||||
};
|
||||
|
||||
var Try = {
|
||||
|
@ -331,7 +331,7 @@
|
||||
},
|
||||
|
||||
testDateToJSON: function() {with(this) {
|
||||
assertEqual('\"1969-12-31T19:00:00\"', new Date(1969, 11, 31, 19).toJSON());
|
||||
assertEqual('\"1970-01-01T00:00:00Z\"', new Date(Date.UTC(1970, 0, 1)).toJSON());
|
||||
}},
|
||||
|
||||
testRegExpEscape: function() {with(this) {
|
||||
|
Loading…
Reference in New Issue
Block a user