Update src/types/ext.ts
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
sora-ext 2025-02-24 15:13:53 +01:00
parent ef00ba536d
commit d295c15504

View File

@ -2,8 +2,10 @@
declare global {
interface Date {
toJSONLocal: () => string;
toLocal: () => string;
}
}
Date.prototype.toJSONLocal = function () {
function addZ(n: number): string {
return n <= 9 ? `0${n}` : `${n}`;
@ -13,7 +15,27 @@ Date.prototype.toJSONLocal = function () {
addZ(this.getMonth() + 1),
addZ(this.getDate()),
].join("-");
};
}
Date.prototype.toLocal = function () {
return [["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"][this.getDay()],
this.getDate(),
[
"Jan",
"Feb",
"Mar",
"Apr",
"May",
"Jun",
"Jul",
"Aug",
"Sep",
"Oct",
"Nov",
"Dec",
][this.getMonth()]].join(" ")
;
}
// ARRAY EXTENTION
declare global {
@ -76,4 +98,4 @@ String.gen_id = function (length) {
.join("");
};
export {};
export { };