Sha256: edd9139d9bcd4f6866a541eaaf640ac12c9e3d531bcfc2b26cc79ebf91ebba46

Contents?: true

Size: 1.51 KB

Versions: 19

Compression:

Stored size: 1.51 KB

Contents

import { daysInMonth } from '../units/month';
import {
    YEAR,
    MONTH,
    DATE,
    HOUR,
    MINUTE,
    SECOND,
    MILLISECOND,
    WEEK,
    WEEKDAY,
} from '../units/constants';
import getParsingFlags from '../create/parsing-flags';

export default function checkOverflow(m) {
    var overflow,
        a = m._a;

    if (a && getParsingFlags(m).overflow === -2) {
        overflow =
            a[MONTH] < 0 || a[MONTH] > 11
                ? MONTH
                : a[DATE] < 1 || a[DATE] > daysInMonth(a[YEAR], a[MONTH])
                ? DATE
                : a[HOUR] < 0 ||
                  a[HOUR] > 24 ||
                  (a[HOUR] === 24 &&
                      (a[MINUTE] !== 0 ||
                          a[SECOND] !== 0 ||
                          a[MILLISECOND] !== 0))
                ? HOUR
                : a[MINUTE] < 0 || a[MINUTE] > 59
                ? MINUTE
                : a[SECOND] < 0 || a[SECOND] > 59
                ? SECOND
                : a[MILLISECOND] < 0 || a[MILLISECOND] > 999
                ? MILLISECOND
                : -1;

        if (
            getParsingFlags(m)._overflowDayOfYear &&
            (overflow < YEAR || overflow > DATE)
        ) {
            overflow = DATE;
        }
        if (getParsingFlags(m)._overflowWeeks && overflow === -1) {
            overflow = WEEK;
        }
        if (getParsingFlags(m)._overflowWeekday && overflow === -1) {
            overflow = WEEKDAY;
        }

        getParsingFlags(m).overflow = overflow;
    }

    return m;
}

Version data entries

19 entries across 19 versions & 1 rubygems

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