2015-12-04 00:28:18 +08:00
|
|
|
'use strict';
|
|
|
|
|
2019-12-24 01:19:08 +08:00
|
|
|
function pad (n) {
|
2015-12-04 00:28:18 +08:00
|
|
|
return n < 10 ? '0' + n : n;
|
|
|
|
}
|
|
|
|
|
2019-12-27 00:46:27 +08:00
|
|
|
/* eslint-disable no-extend-native */
|
2019-12-24 01:19:08 +08:00
|
|
|
Date.prototype.toJSON = function () {
|
2015-12-04 00:28:18 +08:00
|
|
|
var s = this.getFullYear() + '-' + pad(this.getMonth() + 1) + '-' + pad(this.getDate()) + 'T' +
|
|
|
|
pad(this.getHours()) + ':' + pad(this.getMinutes()) + ':' + pad(this.getSeconds());
|
|
|
|
var offset = this.getTimezoneOffset();
|
|
|
|
if (offset === 0) {
|
|
|
|
s += 'Z';
|
|
|
|
} else {
|
2019-12-24 01:19:08 +08:00
|
|
|
s += (offset < 0 ? '+' : '-') + pad(Math.abs(offset / 60)) + pad(Math.abs(offset % 60));
|
2015-12-04 00:28:18 +08:00
|
|
|
}
|
|
|
|
return s;
|
|
|
|
};
|
2019-12-27 00:46:27 +08:00
|
|
|
/* eslint-enable no-extend-native */
|