aboutsummaryrefslogtreecommitdiffstats
path: root/library/moment/src/lib/create/check-overflow.js
diff options
context:
space:
mode:
Diffstat (limited to 'library/moment/src/lib/create/check-overflow.js')
-rw-r--r--library/moment/src/lib/create/check-overflow.js28
1 files changed, 28 insertions, 0 deletions
diff --git a/library/moment/src/lib/create/check-overflow.js b/library/moment/src/lib/create/check-overflow.js
new file mode 100644
index 000000000..88a62ae54
--- /dev/null
+++ b/library/moment/src/lib/create/check-overflow.js
@@ -0,0 +1,28 @@
+import { daysInMonth } from '../units/month';
+import { YEAR, MONTH, DATE, HOUR, MINUTE, SECOND, MILLISECOND } from '../units/constants';
+import getParsingFlags from '../create/parsing-flags';
+
+export default function checkOverflow (m) {
+ var overflow;
+ var 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;
+ }
+
+ getParsingFlags(m).overflow = overflow;
+ }
+
+ return m;
+}
+