aboutsummaryrefslogtreecommitdiff
path: root/deno/mail-relay/better-js.ts
blob: c424a6e75a77738c1bf9db836f77f3f743ca7086 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
declare global {
  interface Date {
    toFileNameString(dateOnly?: boolean): string;
  }
}

Object.defineProperty(Date.prototype, "toFileNameString", {
  value: function (this: Date, dateOnly?: boolean) {
    const str = this.toISOString();
    return dateOnly === true
      ? str.slice(0, str.indexOf("T"))
      : str.replaceAll(/:|\./g, "-");
  },
});