Sha256: c77a21ecce508210c21ad92b189551795fb90f89829f619ee3827b4f8a14204f

Contents?: true

Size: 1.05 KB

Versions: 19

Compression:

Stored size: 1.05 KB

Contents

export function createDate(y, m, d, h, M, s, ms) {
    // can't just apply() to create a date:
    // https://stackoverflow.com/q/181348
    var date;
    // the date constructor remaps years 0-99 to 1900-1999
    if (y < 100 && y >= 0) {
        // preserve leap years using a full 400 year cycle, then reset
        date = new Date(y + 400, m, d, h, M, s, ms);
        if (isFinite(date.getFullYear())) {
            date.setFullYear(y);
        }
    } else {
        date = new Date(y, m, d, h, M, s, ms);
    }

    return date;
}

export function createUTCDate(y) {
    var date, args;
    // the Date.UTC function remaps years 0-99 to 1900-1999
    if (y < 100 && y >= 0) {
        args = Array.prototype.slice.call(arguments);
        // preserve leap years using a full 400 year cycle, then reset
        args[0] = y + 400;
        date = new Date(Date.UTC.apply(null, args));
        if (isFinite(date.getUTCFullYear())) {
            date.setUTCFullYear(y);
        }
    } else {
        date = new Date(Date.UTC.apply(null, arguments));
    }

    return date;
}

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
card-mod-date-0.15.6 vendor/moment/src/lib/create/date-from-array.js
card-mod-date-0.15.0 vendor/moment/src/lib/create/date-from-array.js
card-mod-date-0.14.2 vendor/moment/src/lib/create/date-from-array.js
card-mod-date-0.14.1 vendor/moment/src/lib/create/date-from-array.js
card-mod-date-0.14.0 vendor/moment/src/lib/create/date-from-array.js
card-mod-date-0.13.4 vendor/moment/src/lib/create/date-from-array.js
card-mod-date-0.13.3 vendor/moment/src/lib/create/date-from-array.js
card-mod-date-0.13.2 vendor/moment/src/lib/create/date-from-array.js
card-mod-date-0.13.1 vendor/moment/src/lib/create/date-from-array.js
card-mod-date-0.13.0 vendor/moment/src/lib/create/date-from-array.js
card-mod-date-0.11.7 vendor/moment/src/lib/create/date-from-array.js
card-mod-date-0.12.0 vendor/moment/src/lib/create/date-from-array.js
card-mod-date-0.11.6 vendor/moment/src/lib/create/date-from-array.js
card-mod-date-0.11.5 vendor/moment/src/lib/create/date-from-array.js
card-mod-date-0.11.4 vendor/moment/src/lib/create/date-from-array.js
card-mod-date-0.11.3 vendor/moment/src/lib/create/date-from-array.js
card-mod-date-0.11.2 vendor/moment/src/lib/create/date-from-array.js
card-mod-date-0.11.1 vendor/moment/src/lib/create/date-from-array.js
card-mod-date-0.11.0 vendor/moment/src/lib/create/date-from-array.js