From 3bd03f0d99d00c84c670d826fe4f1950bbbb2a39 Mon Sep 17 00:00:00 2001 From: MillironX <25492070+MillironX@users.noreply.github.com> Date: Tue, 20 Jul 2021 11:13:43 -0500 Subject: [PATCH] Add date optional function --- src/index.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/index.ts b/src/index.ts index d071d25..7bea3ee 100644 --- a/src/index.ts +++ b/src/index.ts @@ -866,3 +866,14 @@ export function generateName(): string { export function generateNameWithNumber() { return `${generateName()}_${Math.floor(Math.random() * 6) + 1}` } + +/** + * Generates a name prepended by today's date in the format YYYYMMDD + * @returns {string} + */ +export function generateNameWithDate() { + var today = new Date(); + today.setMinutes(today.getMinutes() - today.getTimezoneOffset()); + const todayText = today.toISOString().slice(0,10).replace(/-/g,""); + return `${todayText}_${generateName()}` +}