DateUtils refactor, remove moment from the code, timezone fixes.#24446
Conversation
|
@thienlnam Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
|
Doesn't look like the reviewers were linked correctly - updating from the issue |
| // IMPORTANT: load any locales (other than english) that might be passed to moment.locale() | ||
| import 'moment/locale/es'; | ||
| import {zonedTimeToUtc, utcToZonedTime, formatInTimeZone} from 'date-fns-tz'; | ||
| import {es, enGB} from 'date-fns/locale'; |
There was a problem hiding this comment.
Nice. I love the alternative!
It's 3x smaller.
mountiny
left a comment
There was a problem hiding this comment.
Thank you @waterim and everyone who has reviewed this til now. Looking good to me, going to wait for @allroundexperts review and testing
|
Hi @waterim! Can you please mention clear test steps for this? |
|
Hey @allroundexperts |
Reviewer Checklist
Screenshots/VideosWebScreen.Recording.2023-08-22.at.1.24.57.AM.movMobile Web - ChromeScreen.Recording.2023-08-22.at.1.39.27.AM.movMobile Web - SafariScreen.Recording.2023-08-22.at.1.42.46.AM.movDesktopScreen.Recording.2023-08-22.at.1.31.57.AM.moviOSScreen.Recording.2023-08-22.at.1.43.53.AM.movAndroidScreen.Recording.2023-08-22.at.1.41.31.AM.mov |
|
@waterim Can you please upload the screen recordings on all the platforms? |
|
@allroundexperts oh, I see, verifying it rn |
|
Yep, screenshots should work |
|
@allroundexperts Not sure if I understand you correctly, but polyfill works correctly, it takes only IANA timezones, meanwhile on web(without polyfill) Intl.supportedValuesOf("timeZone") is taking different standard ECMAScript Internationalization API which is breaking date-fns functions. |
|
@waterim could you leave a link in the timezones page what is the source so its traceable, thanks! @allroundexperts also ready for another look |
|
@mountiny Added |
allroundexperts
left a comment
There was a problem hiding this comment.
Working good now. Thanks for the changes @waterim!
|
🎯 @allroundexperts, thanks for reviewing and testing this PR! 🎉 An E/App issue has been created to issue payment here: #25619. |
|
🚀 Deployed to staging by https://github.com/mountiny in version: 1.3.56-2 🚀
|
|
FYI, a regression was found here: https://expensify.slack.com/archives/C049HHMV9SM/p1692671896444999 |
|
#25650 issue for above |
|
Heads up this also caused a regression related to marking things as unread on iOS. Web is unaffected. |
|
🚀 Deployed to production by https://github.com/roryabraham in version: 1.3.56-24 🚀
|
|
🚀 Deployed to staging by https://github.com/mountiny in version: 1.3.58-0 🚀
|
|
🚀 Deployed to production by https://github.com/luacmartins in version: 1.3.58-5 🚀
|
|
|
||
| const startOfCurrentWeek = startOfWeek(new Date(), {weekStartsOn: 1}); // Assuming Monday is the start of the week | ||
| const endOfCurrentWeek = endOfWeek(new Date(), {weekStartsOn: 1}); // Assuming Monday is the start of the week | ||
|
|
There was a problem hiding this comment.
This caused regression.
While updating week start day to Monday on header, body still remains as Sunday for the start day
|
|
||
| // If the date is equal to the end of today | ||
| if (input.isSame(endOfToday)) { | ||
| if (isSameDay(input, endOfToday)) { |
There was a problem hiding this comment.
It caused this bug because if we set custom time after 30 minutes, the isSameDay function still returns true
| * @returns {String} | ||
| */ | ||
| function getZoneAbbreviation(datetime, selectedTimezone) { | ||
| return formatInTimeZone(datetime, selectedTimezone, 'zzz'); |
There was a problem hiding this comment.
We still need to provide a specific case for the GMT timezone like our previous logic.
More details:
#80766 (comment)


Details
This PR is about refactoring DateUtils and usage of it, removing all moment and timezone configuration.
Fixed Issues
$ #19810
PROPOSAL: #19810 (comment)
Tests
Offline tests
N/A automated tests
QA Steps
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectiontoggleReportand notonIconClick)myBool && <MyComponent />.src/languages/*files and using the translation methodWaiting for Copylabel for a copy review on the original GH to get the correct copy.STYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)/** comment above it */thisproperly so there are no scoping issues (i.e. foronClick={this.submit}the methodthis.submitshould be bound tothisin the constructor)thisare necessary to be bound (i.e. avoidthis.submit = this.submit.bind(this);ifthis.submitis never passed to a component event handler likeonClick)StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG))Avataris modified, I verified thatAvataris working as expected in all cases)ScrollViewcomponent to make it scrollable when more elements are added to the page.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
N/A automated tests
Web
Mobile Web - Chrome
Mobile Web - Safari
Desktop
iOS
Android