CartoDB-SQL-API/lib/utils/date-to-json.js
Daniel García Aubert 014158c968 Eslint errors
2019-12-26 17:46:27 +01:00

20 lines
593 B
JavaScript

'use strict';
function pad (n) {
return n < 10 ? '0' + n : n;
}
/* eslint-disable no-extend-native */
Date.prototype.toJSON = function () {
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 {
s += (offset < 0 ? '+' : '-') + pad(Math.abs(offset / 60)) + pad(Math.abs(offset % 60));
}
return s;
};
/* eslint-enable no-extend-native */