main
Last change
on this file was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago |
Initial commit
|
-
Property mode
set to
100644
|
File size:
630 bytes
|
Rev | Line | |
---|
[d24f17c] | 1 | /**
|
---|
| 2 | * Polyfill from <https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString>.
|
---|
| 3 | */
|
---|
| 4 | var pad = function pad(n) {
|
---|
| 5 | return (n < 10 ? '0' : '') + n;
|
---|
| 6 | };
|
---|
| 7 |
|
---|
| 8 | var _toISOString = typeof Date.prototype.toISOString === 'function' ? function _toISOString(d) {
|
---|
| 9 | return d.toISOString();
|
---|
| 10 | } : function _toISOString(d) {
|
---|
| 11 | return d.getUTCFullYear() + '-' + pad(d.getUTCMonth() + 1) + '-' + pad(d.getUTCDate()) + 'T' + pad(d.getUTCHours()) + ':' + pad(d.getUTCMinutes()) + ':' + pad(d.getUTCSeconds()) + '.' + (d.getUTCMilliseconds() / 1000).toFixed(3).slice(2, 5) + 'Z';
|
---|
| 12 | };
|
---|
| 13 |
|
---|
| 14 | module.exports = _toISOString; |
---|
Note:
See
TracBrowser
for help on using the repository browser.