summaryrefslogtreecommitdiff
path: root/node_modules/moment/src/lib/parse/token.js
diff options
context:
space:
mode:
authorAlexander Neonxp Kiryukhin <i@neonxp.ru>2024-08-18 13:29:54 +0300
committerAlexander Neonxp Kiryukhin <i@neonxp.ru>2024-08-18 13:29:54 +0300
commitfd70f95224374d23157ee7c0357733102cd0df53 (patch)
treee490c12e021cedaf211b292d5d623baa32a673fc /node_modules/moment/src/lib/parse/token.js
initialHEADmaster
Diffstat (limited to 'node_modules/moment/src/lib/parse/token.js')
-rw-r--r--node_modules/moment/src/lib/parse/token.js36
1 files changed, 36 insertions, 0 deletions
diff --git a/node_modules/moment/src/lib/parse/token.js b/node_modules/moment/src/lib/parse/token.js
new file mode 100644
index 0000000..ede3578
--- /dev/null
+++ b/node_modules/moment/src/lib/parse/token.js
@@ -0,0 +1,36 @@
+import hasOwnProp from '../utils/has-own-prop';
+import isNumber from '../utils/is-number';
+import toInt from '../utils/to-int';
+
+var tokens = {};
+
+export function addParseToken(token, callback) {
+ var i,
+ func = callback,
+ tokenLen;
+ if (typeof token === 'string') {
+ token = [token];
+ }
+ if (isNumber(callback)) {
+ func = function (input, array) {
+ array[callback] = toInt(input);
+ };
+ }
+ tokenLen = token.length;
+ for (i = 0; i < tokenLen; i++) {
+ tokens[token[i]] = func;
+ }
+}
+
+export function addWeekParseToken(token, callback) {
+ addParseToken(token, function (input, array, config, token) {
+ config._w = config._w || {};
+ callback(input, config._w, config, token);
+ });
+}
+
+export function addTimeToArrayFromToken(token, input, config) {
+ if (input != null && hasOwnProp(tokens, token)) {
+ tokens[token](input, config._a, config, token);
+ }
+}