Skip to content

Commit 05b2399

Browse files
ff6347Martin BraunFabian Morón Zirfas
authored
Add Date method toISOString() (#10)
Add Date method toISOString() Co-authored-by: Martin Braun <martin.braun@pagina.gmbh> Co-authored-by: Fabian Morón Zirfas <icke@fabianmoronzirfas.me>
2 parents 1d4a557 + c6681ec commit 05b2399

File tree

5 files changed

+318
-249
lines changed

5 files changed

+318
-249
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
.vscode
2+
13
# Logs
24
logs
35
*.log

Date/toISOString.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*
2+
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString
3+
*/
4+
if (!Date.prototype.toISOString) {
5+
(function() {
6+
7+
function pad(number) {
8+
if (number < 10) {
9+
return '0' + number;
10+
}
11+
return number;
12+
}
13+
14+
Date.prototype.toISOString = function() {
15+
return this.getUTCFullYear() +
16+
'-' + pad(this.getUTCMonth() + 1) +
17+
'-' + pad(this.getUTCDate()) +
18+
'T' + pad(this.getUTCHours()) +
19+
':' + pad(this.getUTCMinutes()) +
20+
':' + pad(this.getUTCSeconds()) +
21+
'.' + (this.getUTCMilliseconds() / 1000).toFixed(3).slice(2, 5) +
22+
'Z';
23+
};
24+
25+
}());
26+
}

bin/concat.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const folders = ['./Array/', './Function/', './Object/', './String/'];
1+
const folders = ['./Array/', './Function/', './Object/', './String/', './Date/'];
22
// const testFolder = './Array/';
33
const fs = require('fs');
44
const path = require('path');

0 commit comments

Comments
 (0)