one of the goals of my pull request, besides simplifying the code was to have localization. It's nice that the browser can handle this, but for consistency, we'll go with vue-i18n since it is already available
8 lines
423 B
TypeScript
8 lines
423 B
TypeScript
export const timestampToString = (locale: string, timestampSeconds: number, includeDays = false): string[] => {
|
|
const timeString = new Date(timestampSeconds * 1000).toLocaleTimeString(locale, { timeZone: "UTC", hour12: false });
|
|
if (!includeDays) return [timeString];
|
|
|
|
const secondsPerDay = 60 * 60 * 24;
|
|
const days = Math.floor(timestampSeconds / secondsPerDay).toFixed(0);
|
|
return [days, timeString];
|
|
} |