FractionOfSecondParser.cjs 634 B

1234567891011121314151617181920212223242526
  1. "use strict";
  2. exports.FractionOfSecondParser = void 0;
  3. var _Parser = require("../Parser.cjs");
  4. var _utils = require("../utils.cjs");
  5. class FractionOfSecondParser extends _Parser.Parser {
  6. priority = 30;
  7. parse(dateString, token) {
  8. const valueCallback = (value) =>
  9. Math.trunc(value * Math.pow(10, -token.length + 3));
  10. return (0, _utils.mapValue)(
  11. (0, _utils.parseNDigits)(token.length, dateString),
  12. valueCallback,
  13. );
  14. }
  15. set(date, _flags, value) {
  16. date.setMilliseconds(value);
  17. return date;
  18. }
  19. incompatibleTokens = ["t", "T"];
  20. }
  21. exports.FractionOfSecondParser = FractionOfSecondParser;