#100 last try to fix this issue
All checks were successful
Lint and Format Check / lint-and-format (pull_request) Successful in 10s

This commit is contained in:
Mylloon 2024-09-24 18:33:57 +02:00
parent b1abeefad2
commit 241a82c395
Signed by: Anri
GPG key ID: A82D63DFF8D1317F

View file

@ -5,8 +5,16 @@
* @param date Date
* @returns String
*/
export const showDate = (tz: string, locale: Map<string, unknown>, date: Date) =>
date.toLocaleString(tz).replace(" ", ` ${locale.get("u_time_at")} `);
export const showDate = (tz: string, locale: Map<string, unknown>, date: Date) => {
const formattedDate = new Intl.DateTimeFormat(tz, {
dateStyle: "short",
timeStyle: "medium",
})
.format(date)
.split(" ");
return `${formattedDate[0]} ${locale.get("u_time_at")} ${formattedDate[1]}`;
};
enum TimeSecond {
Year = 31536000,
@ -63,5 +71,6 @@ export const strToSeconds = (time: string) => {
export const timeDeltaToString = (time: number) => {
const now = Date.now();
// TODO adapt the output and not always parse the time as seconds
// Use Intl.RelativeTimeFormat ?
return `${strToSeconds(`${(now - time) / 1000}`)} secs`;
};