Format datetimes using i18n lang

This commit is contained in:
nimbleghost
2023-07-03 15:24:13 +02:00
parent 7a1488fcd3
commit 311ffc3672
5 changed files with 25 additions and 19 deletions

View File

@@ -130,13 +130,14 @@ export const hashCode = (s) => {
return hash;
};
export const formatShortDateTime = (timestamp) =>
new Intl.DateTimeFormat("default", {
export const formatShortDateTime = (timestamp, language) =>
new Intl.DateTimeFormat(language, {
dateStyle: "short",
timeStyle: "short",
}).format(new Date(timestamp * 1000));
export const formatShortDate = (timestamp) => new Intl.DateTimeFormat("default", { dateStyle: "short" }).format(new Date(timestamp * 1000));
export const formatShortDate = (timestamp, language) =>
new Intl.DateTimeFormat(language, { dateStyle: "short" }).format(new Date(timestamp * 1000));
export const formatBytes = (bytes, decimals = 2) => {
if (bytes === 0) return "0 bytes";