This repository has been archived by the owner on Jan 20, 2024. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
46 additions
and
31 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,16 @@ | ||
import format from "date-fns/format"; | ||
|
||
export const DateFormat = "yyyy-MM-dd"; | ||
export const TimeFormat = "HH:mm"; | ||
|
||
/** | ||
* Converts a JS date to epoch timestamp. | ||
* Converts a JS date to epoch timestamp. Returns `0` on error. | ||
* @param date Date in JS `Date` class | ||
*/ | ||
export const dateTimeToUnixTime = (date: Date) => date.getTime(); | ||
export const dateTimeToUnixTime = (date: Date) => date.getTime() || 0; | ||
|
||
/** | ||
* Expands a Unix epoch timestamp into a string that looks like this: | ||
* "05/29/1453, 12:00 AM" | ||
*/ | ||
export const fmtDate = (date: number) => format(new Date(date), "Pp"); |
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