]> git.ipfire.org Git - thirdparty/moment.git/commitdiff
[bugfix] Fix circular dependency issue (#4906)
authorTremayne Christ <info@tremaynechrist.co.uk>
Fri, 24 Apr 2020 11:41:32 +0000 (12:41 +0100)
committerGitHub <noreply@github.com>
Fri, 24 Apr 2020 11:41:32 +0000 (14:41 +0300)
* split out isLeapYear into separate util

* update month to use isLeapYear util for consistency

src/lib/moment/get-set.js
src/lib/units/month.js
src/lib/units/year.js
src/lib/utils/is-leap-year.js [new file with mode: 0644]

index f5035f1a4b75d1f8c129d28b1312c80768f3d651..f69d09c97fe6a15a9040e3ae56168054151108b0 100644 (file)
@@ -3,7 +3,7 @@ import { getPrioritizedUnits } from '../units/priorities';
 import { hooks } from '../utils/hooks';
 import isFunction from '../utils/is-function';
 import { daysInMonth } from '../units/month';
-import { isLeapYear } from '../units/year';
+import { isLeapYear } from '../utils/is-leap-year';
 
 export function makeGetSet (unit, keepTime) {
     return function (value) {
index f504ed35e233e9851ec768866305506839094f1d..b645373bd9a83bf5726bdd50ffa13e46fa03abb2 100644 (file)
@@ -14,7 +14,7 @@ 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';
+import { isLeapYear } from '../utils/is-leap-year';
 
 export function daysInMonth(year, month) {
     if (isNaN(year) || isNaN(month)) {
index 8f3f94cdab1cea5bcdd4696c0933d13893de7da4..ccbad583e519cfe94467c7357425431b6528b839 100644 (file)
@@ -4,6 +4,7 @@ import { addUnitAlias } from './aliases';
 import { addUnitPriority } from './priorities';
 import { addRegexToken, match1to2, match1to4, match1to6, match2, match4, match6, matchSigned } from '../parse/regex';
 import { addParseToken } from '../parse/token';
+import { isLeapYear } from '../utils/is-leap-year';
 import { hooks } from '../utils/hooks';
 import { YEAR } from './constants';
 import toInt from '../utils/to-int';
@@ -56,9 +57,7 @@ export function daysInYear(year) {
     return isLeapYear(year) ? 366 : 365;
 }
 
-export function isLeapYear(year) {
-    return (year % 4 === 0 && year % 100 !== 0) || year % 400 === 0;
-}
+export { isLeapYear };
 
 // HOOKS
 
diff --git a/src/lib/utils/is-leap-year.js b/src/lib/utils/is-leap-year.js
new file mode 100644 (file)
index 0000000..e399d93
--- /dev/null
@@ -0,0 +1,3 @@
+export function isLeapYear(year) {
+    return (year % 4 === 0 && year % 100 !== 0) || year % 400 === 0;
+}