aboutsummaryrefslogtreecommitdiff
path: root/deno/base/date.ts
diff options
context:
space:
mode:
Diffstat (limited to 'deno/base/date.ts')
-rw-r--r--deno/base/date.ts6
1 files changed, 6 insertions, 0 deletions
diff --git a/deno/base/date.ts b/deno/base/date.ts
new file mode 100644
index 0000000..e65691e
--- /dev/null
+++ b/deno/base/date.ts
@@ -0,0 +1,6 @@
+export function toFileNameString(date: Date, dateOnly?: boolean): string {
+ const str = date.toISOString();
+ return dateOnly === true
+ ? str.slice(0, str.indexOf("T"))
+ : str.replaceAll(/:|\./g, "-");
+}