zhangyong
2023-08-22 1353e87cb21a4032d585d7404bae9042f2ebcf08
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// eslint-disable-next-line valid-typeof
var isBigInt = function isBigInt(num) {
  return typeof num === 'bigint';
};
 
export default (function (o, c, dayjs) {
  var proto = c.prototype;
 
  var parseDate = function parseDate(cfg) {
    var date = cfg.date;
 
    if (isBigInt(date)) {
      return Number(date);
    }
 
    return date;
  };
 
  var oldParse = proto.parse;
 
  proto.parse = function (cfg) {
    cfg.date = parseDate.bind(this)(cfg);
    oldParse.bind(this)(cfg);
  };
 
  var oldUnix = dayjs.unix;
 
  dayjs.unix = function (timestamp) {
    var ts = isBigInt(timestamp) ? Number(timestamp) : timestamp;
    return oldUnix(ts);
  };
});