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

STCOM-1094 Replace momentJS with dayJS #2192

Open
wants to merge 26 commits into
base: master
Choose a base branch
from
Open

STCOM-1094 Replace momentJS with dayJS #2192

wants to merge 26 commits into from

Conversation

JohnC-80
Copy link
Contributor

@JohnC-80 JohnC-80 commented Jan 3, 2024

For many instances, dayJS is a drop-in replacement for moment . There are a handful of differences when dealing with time/timezones.

Most notable was a dayjs bug for the utc plugin when an array of possible formats are provided - the resulting datetime bakes in an offset. This is due to an issue that's surfaced in a dayJS PR - but this shouldn't affect most FOLIO usage at the app level, as that level tends to deal with dates or times exclusinvely in the ISO8601 format if not just a plain string. Further, it was easy enough to circumvent with a small utility method to check the array of intended formats individually.

Additionally was a local implementation of a dayjs range - simply just an array of dayjs objects vs the npm import moment-range. There is a dayJS issue for this with some ideas included.

Importing is also a bit different with Dayjs - to supplant their bullet-point of '2kb' size, they require you to import and extend dayJS through individual plugins that cover anything from advanced formatting to handling UTC time.

Dayjs i18l is pretty straightforward, with their locales broken out into separate modules and load-able via dynamic import - This PR includes some utilities - 1 hook, 1 component to handle this feat (the component uses the hook and it's for non-functional components that can't just use the hook.) Some slight adjustment had to be done in order to support "non-primary/non-native" locale/region combinations ('en-SE') and get weekday alignment on the Calendar working correctly.

This probably represents the biggest lift we'd have to do for removing moment. More datetime library code is here than should be employed at the ui-module level... (aside from ui-calendar, perhaps.)

This comment has been minimized.

Copy link

github-actions bot commented Jan 3, 2024

Jest Unit Test Statistics

0 tests  ±0   0 ✔️ ±0   0s ⏱️ ±0s
0 suites ±0   0 💤 ±0 
0 files   ±0   0 ±0 

Results for commit f4b3355. ± Comparison against base commit 2237df6.

♻️ This comment has been updated with latest results.

This comment has been minimized.

Copy link

github-actions bot commented Jan 3, 2024

BigTest Unit Test Statistics

       1 files  ±  0         1 suites  ±0   11s ⏱️ ±0s
1 438 tests +22  1 418 ✔️ +23  20 💤  - 1  0 ±0 
1 440 runs  +21  1 420 ✔️ +22  20 💤  - 1  0 ±0 

Results for commit f4b3355. ± Comparison against base commit 2237df6.

♻️ This comment has been updated with latest results.

@JohnC-80 JohnC-80 changed the title Replace momentJS with dayJS STCOM-1094 Replace momentJS with dayJS Jan 3, 2024
@JohnC-80 JohnC-80 marked this pull request as ready for review January 4, 2024 14:49
Copy link

sonarcloud bot commented Jan 17, 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants