index.js 648 B

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