aboutsummaryrefslogtreecommitdiff
path: root/node_modules/moment/src/lib/units
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2017-10-14 18:40:54 +0200
committerFlorian Dold <florian.dold@gmail.com>2017-10-14 18:40:54 +0200
commit9df98e65f842cf3acae09cbdd969966f42d64469 (patch)
treef071d3e09a342c208fb8e1cd3f5241d64fbfbaf3 /node_modules/moment/src/lib/units
parent008926b18470e7f394cd640302957b29728a9803 (diff)
update dependencies
Diffstat (limited to 'node_modules/moment/src/lib/units')
-rw-r--r--node_modules/moment/src/lib/units/month.js9
-rw-r--r--node_modules/moment/src/lib/units/year.js2
2 files changed, 9 insertions, 2 deletions
diff --git a/node_modules/moment/src/lib/units/month.js b/node_modules/moment/src/lib/units/month.js
index 28b4a1b98..f504ed35e 100644
--- a/node_modules/moment/src/lib/units/month.js
+++ b/node_modules/moment/src/lib/units/month.js
@@ -10,12 +10,19 @@ import { MONTH } from './constants';
import toInt from '../utils/to-int';
import isArray from '../utils/is-array';
import isNumber from '../utils/is-number';
+import mod from '../utils/mod';
import indexOf from '../utils/index-of';
import { createUTC } from '../create/utc';
import getParsingFlags from '../create/parsing-flags';
+import { isLeapYear } from '../units/year';
export function daysInMonth(year, month) {
- return new Date(Date.UTC(year, month + 1, 0)).getUTCDate();
+ if (isNaN(year) || isNaN(month)) {
+ return NaN;
+ }
+ var modMonth = mod(month, 12);
+ year += (month - modMonth) / 12;
+ return modMonth === 1 ? (isLeapYear(year) ? 29 : 28) : (31 - modMonth % 7 % 2);
}
// FORMATTING
diff --git a/node_modules/moment/src/lib/units/year.js b/node_modules/moment/src/lib/units/year.js
index a10e5b4be..8f3f94cda 100644
--- a/node_modules/moment/src/lib/units/year.js
+++ b/node_modules/moment/src/lib/units/year.js
@@ -56,7 +56,7 @@ export function daysInYear(year) {
return isLeapYear(year) ? 366 : 365;
}
-function isLeapYear(year) {
+export function isLeapYear(year) {
return (year % 4 === 0 && year % 100 !== 0) || year % 400 === 0;
}