2691a211ac91c537c3e276d5aa8848a96501cf8ff9210af43cbf3144716738c104d3dd025ae397e6d31763818eb8885369bc31fd279d1e1d5e08bf3a9e2e26 958 B

123456789101112131415161718192021222324252627282930313233343536
  1. import hasOwnProp from '../utils/has-own-prop';
  2. import isNumber from '../utils/is-number';
  3. import toInt from '../utils/to-int';
  4. var tokens = {};
  5. export function addParseToken(token, callback) {
  6. var i,
  7. func = callback,
  8. tokenLen;
  9. if (typeof token === 'string') {
  10. token = [token];
  11. }
  12. if (isNumber(callback)) {
  13. func = function (input, array) {
  14. array[callback] = toInt(input);
  15. };
  16. }
  17. tokenLen = token.length;
  18. for (i = 0; i < tokenLen; i++) {
  19. tokens[token[i]] = func;
  20. }
  21. }
  22. export function addWeekParseToken(token, callback) {
  23. addParseToken(token, function (input, array, config, token) {
  24. config._w = config._w || {};
  25. callback(input, config._w, config, token);
  26. });
  27. }
  28. export function addTimeToArrayFromToken(token, input, config) {
  29. if (input != null && hasOwnProp(tokens, token)) {
  30. tokens[token](input, config._a, config, token);
  31. }
  32. }