This repository has been archived by the owner on Oct 27, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 36
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
59 changed files
with
415 additions
and
258 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
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,21 +1,26 @@ | ||
import { formatDistanceStrict } from "date-fns"; | ||
|
||
export const formatDate = (date: number | string | Date, joiner = "/") => { | ||
const d = ["string", "number"].includes(typeof date) | ||
? new Date(date) | ||
: (date as Date); | ||
return [ | ||
`0${d.getDate()}`.slice(-2), | ||
`0${d.getMonth() + 1}`.slice(-2), | ||
d.getFullYear() | ||
].join(joiner); | ||
try { | ||
const d = ["string", "number"].includes(typeof date) | ||
? new Date(date) | ||
: (date as Date); | ||
return [ | ||
`0${d.getDate()}`.slice(-2), | ||
`0${d.getMonth() + 1}`.slice(-2), | ||
d.getFullYear() | ||
].join(joiner); | ||
} catch (e) { | ||
console.debug(e); | ||
return `0`; | ||
} | ||
}; | ||
|
||
export const getTimeDifferenceInWords = (date: Date, dateToCompare: Date) => { | ||
try { | ||
return formatDistanceStrict(date, dateToCompare); | ||
} catch (e) { | ||
console.error(e); | ||
console.debug(e); | ||
return `0`; | ||
} | ||
}; |
Oops, something went wrong.