]> git.ipfire.org Git - thirdparty/moment.git/commitdiff
Finish a bunch of TODOs
authorTim Wood <washwithcare@gmail.com>
Thu, 22 Jan 2015 16:49:38 +0000 (08:49 -0800)
committerIskren Chernev <iskren.chernev@gmail.com>
Wed, 25 Mar 2015 16:27:42 +0000 (09:27 -0700)
lib/units/day-of-month.js
lib/units/hour.js
lib/units/millisecond.js
lib/units/minute.js
lib/units/month.js
lib/units/quarter.js
lib/units/second.js
lib/units/year.js

index bd58d5cdcbfa72ef17fc227a110c663a3988fc71..bc50abee292016e03fd5226273d56e693e4d807c 100644 (file)
@@ -3,6 +3,7 @@ import { addFormatToken } from "../format/format";
 import { addUnitAlias } from "./aliases";
 import { addRegexToken, match1to2, match2 } from "../parse/regex";
 import { addParseToken } from "../parse/token";
+import { DATE } from "./constants";
 import toInt from "../utils/to-int";
 
 // FORMATTING
@@ -21,9 +22,9 @@ addRegexToken("Do", function (isStrict, locale) {
     return isStrict ? locale._ordinalParse : locale._ordinalParseLenient;
 });
 
-addParseToken(["D", "DD"], 2); // TODO: use a constant for DATE
+addParseToken(["D", "DD"], DATE);
 addParseToken("Do", function (input, array) {
-    array[2] = toInt(input.match(match1to2)[0], 10); // TODO: use a constant for DATE
+    array[DATE] = toInt(input.match(match1to2)[0], 10);
 });
 
 // MOMENTS
index d8d7c6015d97a949b018917ff4e76a2e0c3e504f..0b926ee49fce04b24be8196c21f384428bf39630 100644 (file)
@@ -3,6 +3,7 @@ import { addFormatToken } from "../format/format";
 import { addUnitAlias } from "./aliases";
 import { addRegexToken, match1to2, match2 } from "../parse/regex";
 import { addParseToken } from "../parse/token";
+import { HOUR } from "./constants";
 import toInt from "../utils/to-int";
 
 // FORMATTING
@@ -38,13 +39,13 @@ addRegexToken("h",  match1to2);
 addRegexToken("HH", match1to2, match2);
 addRegexToken("hh", match1to2, match2);
 
-addParseToken(["H", "HH"], 3); // TODO: use a constant for HOUR
+addParseToken(["H", "HH"], HOUR);
 addParseToken(["a", "A"], function (input, array, config) {
    config._isPm = config._locale.isPM(input);
    config._meridiem = input;
 });
 addParseToken(["h", "hh"], function (input, array, config) {
-    array[3] = toInt(input); // TODO: use a constant for HOUR
+    array[HOUR] = toInt(input);
     config._pf.bigHour = true;
 });
 
index 2dac76916daf73204ba0343aed49b965a1c4bf37..3e9c3793d8cbaab070c053f860d7cf8894ce1fd2 100644 (file)
@@ -3,6 +3,7 @@ import { addFormatToken } from "../format/format";
 import { addUnitAlias } from "./aliases";
 import { addRegexToken, match1, match2, match3, match1to3, matchUnsigned } from "../parse/regex";
 import { addParseToken } from "../parse/token";
+import { MILLISECOND } from "./constants";
 import toInt from "../utils/to-int";
 
 // FORMATTING
@@ -33,7 +34,7 @@ addRegexToken("SS",   match1to3, match2);
 addRegexToken("SSS",  match1to3, match3);
 addRegexToken("SSSS", matchUnsigned);
 addParseToken(["S", "SS", "SSS", "SSSS"], function (input, array) {
-    array[6] = toInt(('0.' + input) * 1000); // TODO: use a constant for MILLISECOND
+    array[MILLISECOND] = toInt(('0.' + input) * 1000);
 });
 
 // MOMENTS
index c3b681f79554fd0c875a3299c012846dd29854eb..dfea040c2be6742885141bbcc3c09c9fddc04355 100644 (file)
@@ -3,6 +3,7 @@ import { addFormatToken } from "../format/format";
 import { addUnitAlias } from "./aliases";
 import { addRegexToken, match1to2, match2 } from "../parse/regex";
 import { addParseToken } from "../parse/token";
+import { MINUTE } from "./constants";
 
 // FORMATTING
 
@@ -16,7 +17,7 @@ addUnitAlias("minute", "m");
 
 addRegexToken("m",  match1to2);
 addRegexToken("mm", match1to2, match2);
-addParseToken(["m", "mm"], 4); // TODO: use a constant for MINUTE
+addParseToken(["m", "mm"], MINUTE);
 
 // MOMENTS
 
index b183e875b75d77379c9b7ed7376694d8e587ad81..d59eb35af0b6a8e58ade305a1a4e2001f2b43afa 100644 (file)
@@ -4,6 +4,7 @@ import { addUnitAlias } from "./aliases";
 import { addRegexToken, match1to2, match2, matchWord } from "../parse/regex";
 import { addParseToken } from "../parse/token";
 import { hooks } from "../utils/hooks";
+import { MONTH } from "./constants";
 import toInt from "../utils/to-int";
 import { createUTC } from "../create/utc";
 
@@ -37,14 +38,14 @@ addRegexToken("MMM",  matchWord);
 addRegexToken("MMMM", matchWord);
 
 addParseToken(["M", "MM"], function (input, array) {
-    array[1] = toInt(input) - 1; // TODO: use a constant for MONTH
+    array[MONTH] = toInt(input) - 1;
 });
 
 addParseToken(["MMM", "MMMM"], function (input, array, config, token) {
     var month = config._locale.monthsParse(input, token, config._strict);
     // if we didn't find a month name, mark the date as invalid.
     if (month != null) {
-        array[1] = month; // TODO: use a constant for MONTH
+        array[MONTH] = month;
     } else {
         config._pf.invalidMonth = input;
     }
index d7df2582cd43a9d3aae2f8057cce80b67eb821c3..c0dc4214b66f2c4c023ad7cf7c77be9a7509dfa3 100644 (file)
@@ -2,6 +2,7 @@ import { addFormatToken } from "../format/format";
 import { addUnitAlias } from "./aliases";
 import { addRegexToken, match1 } from "../parse/regex";
 import { addParseToken } from "../parse/token";
+import { MONTH } from "./constants";
 import toInt from "../utils/to-int";
 
 // FORMATTING
@@ -16,7 +17,7 @@ addUnitAlias("quarter", "Q");
 
 addRegexToken("Q", match1);
 addParseToken("Q", function (input, array) {
-    array[1] = (toInt(input) - 1) * 3; // TODO: use a constant for MONTH
+    array[MONTH] = (toInt(input) - 1) * 3;
 });
 
 // MOMENTS
index 8cab5af6d395c5725de45c2aa48af2ca9a4e0a40..8eaa35a7b0bf3b2a6bbc22509836bd72d093efda 100644 (file)
@@ -3,6 +3,7 @@ import { addFormatToken } from "../format/format";
 import { addUnitAlias } from "./aliases";
 import { addRegexToken, match1to2, match2 } from "../parse/regex";
 import { addParseToken } from "../parse/token";
+import { SECOND } from "./constants";
 
 // FORMATTING
 
@@ -16,7 +17,7 @@ addUnitAlias("second", "s");
 
 addRegexToken("s",  match1to2);
 addRegexToken("ss", match1to2, match2);
-addParseToken(["s", "ss"], 5); // TODO: use a constant for SECOND
+addParseToken(["s", "ss"], SECOND);
 
 // MOMENTS
 
index 8b85b86a9cc341aa66669a6404d9f40446c991ff..94dd0ca72d0171ee0b53e74fda9d2e4d9c2ba20b 100644 (file)
@@ -4,6 +4,7 @@ import { addUnitAlias } from "./aliases";
 import { addRegexToken, match1to2, match1to4, match1to6, match2, match4, match6, matchSigned } from "../parse/regex";
 import { addParseToken } from "../parse/token";
 import { hooks } from "../utils/hooks";
+import { YEAR } from "./constants";
 import toInt from "../utils/to-int";
 
 // FORMATTING
@@ -28,9 +29,9 @@ addRegexToken("YYYY",   match1to4, match4);
 addRegexToken("YYYYY",  match1to6, match6);
 addRegexToken("YYYYYY", match1to6, match6);
 
-addParseToken(["YYYY", "YYYYY", "YYYYYY"], 0);
+addParseToken(["YYYY", "YYYYY", "YYYYYY"], YEAR);
 addParseToken("YY", function (input, array) {
-    array[0] = hooks.parseTwoDigitYear(input);
+    array[YEAR] = hooks.parseTwoDigitYear(input);
 });
 
 // HELPERS