PageRenderTime 17ms CodeModel.GetById 14ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/node_modules/moment/src/lib/create/date-from-array.js

https://bitbucket.org/coleman333/smartsite
JavaScript | 21 lines | 14 code | 3 blank | 4 comment | 6 complexity | 15a708089f97261dd39317e2f9ddaebc MD5 | raw file
 1export function createDate (y, m, d, h, M, s, ms) {
 2    // can't just apply() to create a date:
 3    // https://stackoverflow.com/q/181348
 4    var date = new Date(y, m, d, h, M, s, ms);
 5
 6    // the date constructor remaps years 0-99 to 1900-1999
 7    if (y < 100 && y >= 0 && isFinite(date.getFullYear())) {
 8        date.setFullYear(y);
 9    }
10    return date;
11}
12
13export function createUTCDate (y) {
14    var date = new Date(Date.UTC.apply(null, arguments));
15
16    // the Date.UTC function remaps years 0-99 to 1900-1999
17    if (y < 100 && y >= 0 && isFinite(date.getUTCFullYear())) {
18        date.setUTCFullYear(y);
19    }
20    return date;
21}