Blame view

天文台pc/tianwentai-ui/node_modules/date-fns/parse/_lib/parsers/FractionOfSecondParser.mjs 494 Bytes
bc518174   王天杨   提交两个项目文件
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
  import { Parser } from "../Parser.mjs";
  import { mapValue, parseNDigits } from "../utils.mjs";
  
  export class FractionOfSecondParser extends Parser {
    priority = 30;
  
    parse(dateString, token) {
      const valueCallback = (value) =>
        Math.trunc(value * Math.pow(10, -token.length + 3));
      return mapValue(parseNDigits(token.length, dateString), valueCallback);
    }
  
    set(date, _flags, value) {
      date.setMilliseconds(value);
      return date;
    }
  
    incompatibleTokens = ["t", "T"];
  }