blob: a23dd0ba06db70776cfeed5822e1688e7f3ad0b2 (
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 (dateOnly?: boolean) {
const str = (this as Date).toISOString();
return dateOnly === true
? str.slice(0, str.indexOf("T"))
: str.replaceAll(/:|\./g, "-");
},
});
|