From d295c1550433c201e6e293ff36cb88c15ff9030a Mon Sep 17 00:00:00 2001 From: sora-ext Date: Mon, 24 Feb 2025 15:13:53 +0100 Subject: [PATCH] Update src/types/ext.ts --- src/types/ext.ts | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/src/types/ext.ts b/src/types/ext.ts index cddb2b8..c13aa39 100644 --- a/src/types/ext.ts +++ b/src/types/ext.ts @@ -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 { };