Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: dayjs locale format seconds is not working and is polluting the global dayjs locale #1689

Merged
merged 24 commits into from
May 8, 2024
Merged
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
51f0a62
fix: dayjs seconds format has bug and affects global packages
nikosrossolatos Jan 1, 2024
aaa27cb
fix: lint issues. Ignore coverage in eslint (#1784)
tomiir Jan 19, 2024
beafcbd
chore: bump to 3.5.7 (#1783)
tomiir Jan 19, 2024
c03424c
feat: added native example wallets deeplinks (#1804)
ganchoradkov Jan 29, 2024
21137fe
Merge branch 'V3' into fix/dayjs-seconds
xzilja Feb 5, 2024
f9bfaf9
refactor: update dateutil tests
enesozturk Apr 8, 2024
9de2760
Merge branch 'V4' into fix/dayjs-seconds
enesozturk Apr 8, 2024
d1ee9e0
chore: revert changes
enesozturk Apr 8, 2024
f9a91c4
chore: add github token to pr checks for tests
enesozturk Apr 8, 2024
940d404
refactor: update gh workflow permission changes
enesozturk Apr 8, 2024
a0d4bd4
Merge branch 'V4' into fix/dayjs-seconds
enesozturk Apr 8, 2024
8548b48
chore: update workflow permission configs
enesozturk Apr 8, 2024
4018017
Merge branch 'V4' into fix/dayjs-seconds
enesozturk Apr 23, 2024
6fb0d8b
refactor: update workflow permissions
enesozturk Apr 23, 2024
0209df9
chore: update ui tests permissions
enesozturk Apr 23, 2024
e46bb10
chore: override pr checks permissions
enesozturk Apr 23, 2024
d0909e8
chore: add write permissions to ui tests
enesozturk Apr 23, 2024
a34d71f
chore: revert workflow permission changes
enesozturk Apr 23, 2024
d65c757
Merge branch 'V4' into fix/dayjs-seconds
enesozturk May 7, 2024
f31c38c
Merge branch 'V4' into fix/dayjs-seconds
tomiir May 7, 2024
f98db4c
Merge branch 'V4' into fix/dayjs-seconds
tomiir May 7, 2024
c24a6cb
Merge branch 'V4' into fix/dayjs-seconds
tomiir May 8, 2024
cb3d575
chore: add permissions to the ui tests
enesozturk May 8, 2024
fcdb768
fix: permissions
enesozturk May 8, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions packages/common/src/utils/DateUtil.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
import dayjs from 'dayjs'
import updateLocale from 'dayjs/plugin/updateLocale.js'
import englishLocale from 'dayjs/locale/en'
import relativeTime from 'dayjs/plugin/relativeTime.js'
import updateLocale from 'dayjs/plugin/updateLocale.js'

dayjs.extend(relativeTime)
dayjs.extend(updateLocale)

dayjs.updateLocale('en', {
const localeObject = {
...englishLocale,
name: 'en-web3-modal',
relativeTime: {
future: 'in %s',
past: '%s ago',
s: '%s sec',
s: '%d sec',
nikosrossolatos marked this conversation as resolved.
Show resolved Hide resolved
m: '1 min',
mm: '%d min',
h: '1 hr',
Expand All @@ -21,14 +24,16 @@ dayjs.updateLocale('en', {
y: '1 yr',
yy: '%d yr'
}
})
}

dayjs.locale('en-web3-modal', localeObject)

export const DateUtil = {
getYear(date: string = new Date().toISOString()) {
return dayjs(date).year()
},

getRelativeDateFromNow(date: string | number) {
return dayjs(date).fromNow(true)
return dayjs(date).locale('en-web3-modal').fromNow(true)
nikosrossolatos marked this conversation as resolved.
Show resolved Hide resolved
}
}
Loading