-
Notifications
You must be signed in to change notification settings - Fork 30
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
Issue #1054 - Replacing moment by dayjs #1067
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Having to extend dayjs every time we need to use it is not a good option.
Please follow the steps here to globally extend dayjs:
iamkun/dayjs#1577
This will have to be done both in the server and client packages
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm pretty sure using the method I linked above, we do not need to import from a custom dayjs file to get the extensions working.
import dayjs from '../../utils/dayjs';
should be import dayjs from 'dayjs';
everywhere
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you misunderstood, I don't want to have to import dayjs from an utils, I want to be able to have import dayjs from 'dayjs';
and have it already extended, the issue I linked explains how
…dule to use in internal files
dayjs.extend(relativeTime); | ||
dayjs.extend(utc); | ||
|
||
export default dayjs; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should avoid exporting it to prevent picking it as a reference when using it in other files
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please revert your changes to this file, the diff contains a lot of file formatting, only keep changes regarding moment/dayjs
@@ -16,13 +16,13 @@ const GlobalTournamentView = () => { | |||
return ( | |||
<Page title={`${bruteName || ''} ${t('MyBrute')}`} headerUrl={`/${bruteName || ''}/cell`}> | |||
<Paper sx={{ mx: 4 }}> | |||
<Text h3 bold upperCase typo="handwritten" sx={{ mr: 2 }}>{t('globalTournamentOf')} {moment.utc(date).format('DD/MM/YYYY')}</Text> | |||
<Text h3 bold upperCase typo="handwritten" sx={{ mr: 2 }}>{t('globalTournamentOf')} {dayjs(date).format('DD/MM/YYYY')}</Text> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<Text h3 bold upperCase typo="handwritten" sx={{ mr: 2 }}>{t('globalTournamentOf')} {dayjs(date).format('DD/MM/YYYY')}</Text> | |
<Text h3 bold upperCase typo="handwritten" sx={{ mr: 2 }}>{t('globalTournamentOf')} {dayjs.utc(date).format('DD/MM/YYYY')}</Text> |
@@ -32,7 +32,7 @@ const PatchNotesView = () => { | |||
</Paper> | |||
{displayedReleases.map((release) => ( | |||
<Paper key={release.version} sx={{ bgcolor: 'background.paperLight', my: 3 }}> | |||
<Text h4 bold upperCase>v{release.version} <Text component="span" italic upperCase>{moment(release.date).format('DD MMMM YYYY')}</Text></Text> | |||
<Text h4 bold upperCase>v{release.version} <Text component="span" italic upperCase>{dayjs(release.date).format('DD MMMM YYYY')}</Text></Text> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The original was missing the utc usage
<Text h4 bold upperCase>v{release.version} <Text component="span" italic upperCase>{dayjs(release.date).format('DD MMMM YYYY')}</Text></Text> | |
<Text h4 bold upperCase>v{release.version} <Text component="span" italic upperCase>{dayjs.utc(release.date).format('DD MMMM YYYY')}</Text></Text> |
@@ -177,7 +177,7 @@ const ClanThreadView = () => { | |||
<Box component="img" src="/images/clan/master.gif" sx={{ ml: 1, width: 7 }} /> | |||
)} | |||
</Box> | |||
<Text color="primary">{moment(post.date).format('D MMM YYYY HH:mm')}</Text> | |||
<Text color="primary">{dayjs(post.date).format('D MMM YYYY HH:mm')}</Text> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing utc in the original code
<Text color="primary">{dayjs(post.date).format('D MMM YYYY HH:mm')}</Text> | |
<Text color="primary">{dayjs.utc(post.date).format('D MMM YYYY HH:mm')}</Text> |
@@ -1,7 +1,7 @@ | |||
import { | |||
Event, EventStatus, FightModifier, PrismaClient, | |||
} from '@labrute/prisma'; | |||
import moment from 'moment'; | |||
import dayjs from './dayjs.js'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
import dayjs from './dayjs.js'; | |
import dayjs from 'dayjs'; |
import translate from './translate.js'; | ||
import ServerState from './ServerState.js'; | ||
import dayjs from './dayjs.js'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
import dayjs from './dayjs.js'; | |
import dayjs from 'dayjs'; |
import ServerState from '../ServerState.js'; | ||
import translate from '../translate.js'; | ||
import checkLevelUpAchievements from './checkLevelUpAchievements.js'; | ||
import getOpponents from './getOpponents.js'; | ||
import { removeChoiceFromDestiny } from './removeChoiceFromDestiny.js'; | ||
import dayjs from '../dayjs.js'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
import dayjs from '../dayjs.js'; | |
import dayjs from 'dayjs'; |
dayjs.extend(utc); | ||
dayjs.extend(isSameOrBefore); | ||
|
||
export default dayjs; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
export default dayjs; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see this file being imported anywhere, shouldn't it be imported in the core index file?
Are you still working on this @Abanoub321 ? |
No description provided.