mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-08-11 19:22:31 +08:00
client: date formatter utility: improve
This commit is contained in:
parent
89334691b7
commit
74ace248d5
@ -12,9 +12,11 @@ export function formatDateTime(date, dateStyle = "medium", timeStyle = "medium")
|
|||||||
// Parse the given string as a date
|
// Parse the given string as a date
|
||||||
parsedDate = new Date(date);
|
parsedDate = new Date(date);
|
||||||
} else if (typeof date === "number" || date instanceof Date) {
|
} else if (typeof date === "number" || date instanceof Date) {
|
||||||
|
// The given date is already a Date instance or a number
|
||||||
parsedDate = date;
|
parsedDate = date;
|
||||||
} else {
|
} else {
|
||||||
throw new TypeError();
|
// Invalid type
|
||||||
|
throw new TypeError(`Invalid type for the "date" argument.`);
|
||||||
};
|
};
|
||||||
|
|
||||||
if (timeStyle === "none") {
|
if (timeStyle === "none") {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user