mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-08-10 02:02:29 +08:00
client: create a date formatter utility
This commit is contained in:
parent
018557bb57
commit
b097a8fc37
14
src/public/app/utils/formatters.js
Normal file
14
src/public/app/utils/formatters.js
Normal file
@ -0,0 +1,14 @@
|
||||
/**
|
||||
* Formats the given date to a string based on the current locale.
|
||||
* @param {Date | number} date
|
||||
* @param {"full" | "long" | "medium" | "short" | undefined} dateStyle
|
||||
* @param {"full" | "long" | "medium" | "short" | undefined} tiemStyle
|
||||
*/
|
||||
export function formatDate(date, dateStyle = "medium", tiemStyle = "medium") {
|
||||
const formatter = new Intl.DateTimeFormat(navigator.language, {
|
||||
dateStyle: "medium",
|
||||
timeStyle: "medium"
|
||||
});
|
||||
|
||||
return formatter.format(date);
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user