File size: 517 Bytes
a572854
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import dayjs from "dayjs";
import utc from "dayjs/plugin/utc";
import timezone from "dayjs/plugin/timezone";

dayjs.extend(utc);
dayjs.extend(timezone);

const localTimezone = Intl.DateTimeFormat().resolvedOptions().timeZone;
dayjs.tz.setDefault(localTimezone);

const originalFormat = dayjs.prototype.format;
dayjs.prototype.format = function (template: string) {
  if (template === "YYYY-MM-DDTHH:mm:ssZ") {
    return this.toISOString();
  }
  return originalFormat.call(this, template);
};

export default dayjs;