From 74ace248d5dde8a32e37e50bbf2f858d75a379f4 Mon Sep 17 00:00:00 2001 From: Adorian Doran Date: Tue, 10 Dec 2024 18:48:48 +0200 Subject: [PATCH] client: date formatter utility: improve --- src/public/app/utils/formatters.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/public/app/utils/formatters.js b/src/public/app/utils/formatters.js index 2c996bb80..638404c89 100644 --- a/src/public/app/utils/formatters.js +++ b/src/public/app/utils/formatters.js @@ -12,9 +12,11 @@ export function formatDateTime(date, dateStyle = "medium", timeStyle = "medium") // Parse the given string as a date parsedDate = new Date(date); } else if (typeof date === "number" || date instanceof Date) { + // The given date is already a Date instance or a number parsedDate = date; } else { - throw new TypeError(); + // Invalid type + throw new TypeError(`Invalid type for the "date" argument.`); }; if (timeStyle === "none") {