-
-
Notifications
You must be signed in to change notification settings - Fork 511
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
- Loading branch information
Showing
6 changed files
with
16 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
export const timestampToString = (timestampSeconds: number, includeDays = false): string => { | ||
const timeString = new Date(timestampSeconds * 1000).toLocaleTimeString([], { timeZone: "UTC" }); | ||
if (!includeDays) return timeString; | ||
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); | ||
return new Intl.RelativeTimeFormat().format(-days, "day") + " " + timeString; | ||
const days = Math.floor(timestampSeconds / secondsPerDay).toFixed(0); | ||
return [days, timeString]; | ||
} |