fix count being a string
This commit is contained in:
parent
f26e824247
commit
caaa7b6347
@ -1,8 +1,10 @@
|
||||
export const timestampToString = (locale: string, timestampSeconds: number, includeDays = false): string[] => {
|
||||
export function timestampToString(locale: string, timestampSeconds: number, includeDays: true): [number, string];
|
||||
export function timestampToString(locale: string, timestampSeconds: number, includeDays?: false): [string];
|
||||
export function timestampToString(locale: string, timestampSeconds: number, includeDays = false): [number, string] | [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);
|
||||
const days = Math.floor(timestampSeconds / secondsPerDay);
|
||||
return [days, timeString];
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user