From 1553ce7eedff9e5e0ab8c3765adc3d1b9e57de96 Mon Sep 17 00:00:00 2001 From: defifofum Date: Mon, 13 May 2024 15:31:58 -0500 Subject: [PATCH] fix(lib): Update dateHelper to remove `:` from name for Windows computers --- lib/node/dateHelper.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/node/dateHelper.ts b/lib/node/dateHelper.ts index b3e49c2..fbd2bc7 100644 --- a/lib/node/dateHelper.ts +++ b/lib/node/dateHelper.ts @@ -1,5 +1,4 @@ -const toISOStringNoHyphens = (date: Date) => date.toISOString().replace(/-/g, '') - +const toISOStringNoHyphens = (date: Date) => date.toISOString().replace(/[-:]/g, '') /** * Gets the current date as a string in the format YYYYMMDD. * This can be used for generating file names or any other date-based identifiers. @@ -8,7 +7,7 @@ const toISOStringNoHyphens = (date: Date) => date.toISOString().replace(/-/g, '' * @param {Date} date (optional) The date to convert to a string in the format YYYYMMDD. Defaults to the current date. * @returns {string} The current date as a string in the format YYYYMMDD. */ -export const getDateDayString = (date = new Date()) => toISOStringNoHyphens(date).slice(0, 8) +export const getDateDayString = (date = new Date()) => toISOStringNoHyphens(date).slice(0, 7) /** * Gets the current date and time as a string in the format YYYYMMDDTHH:MM. @@ -18,7 +17,7 @@ export const getDateDayString = (date = new Date()) => toISOStringNoHyphens(date * @param {Date} date (optional) The date to convert to a string in the format YYYYMMDDTHH:MM. Defaults to the current date. * @returns {string} The current date and time as a string in the format YYYYMMDDTHH:MM. */ -export const getDateMinuteString = (date = new Date()) => toISOStringNoHyphens(date).slice(0, 14) +export const getDateMinuteString = (date = new Date()) => toISOStringNoHyphens(date).slice(0, 13) export const getDaysAgo = (dateString: string): number => { const date = new Date(dateString)