diff options
Diffstat (limited to 'library/moment/src/lib/create/date-from-array.js')
-rw-r--r-- | library/moment/src/lib/create/date-from-array.js | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/library/moment/src/lib/create/date-from-array.js b/library/moment/src/lib/create/date-from-array.js new file mode 100644 index 000000000..349eebcc4 --- /dev/null +++ b/library/moment/src/lib/create/date-from-array.js @@ -0,0 +1,19 @@ +export function createDate (y, m, d, h, M, s, ms) { + //can't just apply() to create a date: + //http://stackoverflow.com/questions/181348/instantiating-a-javascript-object-by-calling-prototype-constructor-apply + var date = new Date(y, m, d, h, M, s, ms); + + //the date constructor doesn't accept years < 1970 + if (y < 1970) { + date.setFullYear(y); + } + return date; +} + +export function createUTCDate (y) { + var date = new Date(Date.UTC.apply(null, arguments)); + if (y < 1970) { + date.setUTCFullYear(y); + } + return date; +} |