-
Notifications
You must be signed in to change notification settings - Fork 58
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
13 changed files
with
142 additions
and
27 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import dayjs from 'dayjs'; | ||
|
||
export const getTimeFrom = (timestamp?: string): string => { | ||
const res = dayjs(timestamp ?? 0) | ||
.utc(true) | ||
.fromNow(true); | ||
|
||
return res; | ||
}; |
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './getTimeFrom'; |
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 |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// main library | ||
import dayjs from 'dayjs'; | ||
|
||
// plugins | ||
import advancedFormat from 'dayjs/plugin/advancedFormat'; | ||
import relativeTime from 'dayjs/plugin/relativeTime'; | ||
import updateLocale from 'dayjs/plugin/updateLocale'; | ||
import utc from 'dayjs/plugin/utc'; | ||
import localizedFormat from 'dayjs/plugin/localizedFormat'; | ||
|
||
const localeList = dayjs.Ls; | ||
|
||
// extend dayjs with plugins | ||
dayjs.extend(advancedFormat); | ||
dayjs.extend(relativeTime); | ||
dayjs.extend(updateLocale); | ||
dayjs.extend(utc); | ||
dayjs.extend(localizedFormat); | ||
|
||
dayjs.updateLocale('en', { | ||
relativeTime: { | ||
...localeList.en.relativeTime, | ||
future: 'in %s', | ||
past: '%s ago', | ||
s: '1m', | ||
m: '1m', | ||
mm: '%dm', | ||
h: '1h', | ||
hh: '%dh', | ||
d: '1d', | ||
dd: '%dd', | ||
M: '30d', | ||
MM: '%dM', | ||
y: '1y', | ||
yy: '%dy', | ||
}, | ||
}); | ||
|
||
// send it back (for use in other files) | ||
export default dayjs; |
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