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

Find alternative to moment.js #191

Open
11 tasks
lorang92 opened this issue Sep 15, 2020 · 8 comments
Open
11 tasks

Find alternative to moment.js #191

lorang92 opened this issue Sep 15, 2020 · 8 comments
Labels
kind/user-story Used for issues that describes functionality for our users. quality/debt

Comments

@lorang92
Copy link
Contributor

lorang92 commented Sep 15, 2020

Description

As moment.js has nearly declared itself dead (https://momentjs.com/docs/#/-project-status/)

In most cases, you should not choose Moment for new projects.
We may choose to not fix bugs or behavioral quirks, especially if they are long-standing known issues.

We should find an alternative project to handle date/time in app-frontend.
Some alternatives may be: https://blog.logrocket.com/4-alternatives-to-moment-js-for-internationalizing-dates/

Acceptance criteria

A viable alternative is identified and has replaced moment.js where used.

Specification tasks

  • Identify where moment.js is used
  • Test design / decide test need

Development tasks

  • Replace with new library
  • Regression test

Definition of done

Verify that this issue meets DoD (Only for project members) before closing.

  • Documentation is updated (if relevant)
    • Technical documentation (docs.altinn.studio)
    • User documentation (altinn.github.io/docs)
  • QA
  • Manual test is complete (if relevant)
  • Automated test is implemented (if relevant)
  • All tasks in this userstory are closed (i.e. remaining tasks are moved to other user stories or marked obsolete)
@lorang92 lorang92 added kind/user-story Used for issues that describes functionality for our users. solution/app-frontend labels Sep 15, 2020
@nkylstad
Copy link
Member

nkylstad commented Jun 2, 2021

@altinnadmin
Copy link
Member

Yeah, I guess we should do the "Identify where moment.js is used" task first.
If we're lucky, native functionality could cover our needs.

@RonnyB71
Copy link
Member

RonnyB71 commented Aug 8, 2023

Moving this to later this year as we would like to use the new date picker implementation from the design system. The date picker is currently not top priority on neither backlogs, so waiting is fine.

cc: @mrosvik

@mikaelrss
Copy link
Contributor

We've added a formatDateLocale function in this pr #1610 which uses the native browser API to format dates. This would probably reduce the efforts of refactoring away from moment.

@bjosttveit bjosttveit removed their assignment Dec 6, 2023
@RonnyB71
Copy link
Member

#602

@bjorntore
Copy link

Just for info, not a strong recommendation by any means: In a previous project the team moved from moment.js to day.js, and that was very easy to do. Exactly the same API, so fixed most of it using Find and replace "momen()" with "dayjs()" (and imports).

@altinnadmin
Copy link
Member

altinnadmin commented Jan 15, 2024

In a previous project the team moved from moment.js to day.js, and that was very easy to do

Yeah, also according to the recommendations from the moment team, Day.js seems like the simplest replacement. Are there any good reasons for not just doing that?

@mikaelrss
Copy link
Contributor

mikaelrss commented Jan 15, 2024

I am not sure if this is a show stopper, but the only thing I can think of at the top of my head is i18n and different date formatting for different locales. We support essentially any language in our apps, and would therefore have to preload every known locale (or default to norwegian/english for ones we decide to not support). I guess we might be able to solve this with code splitting and dynamically loading locales, but I think that might be a bit complex.

If we were able to rely on the native browser Intl API instead, we could be able to support any locale, but I am not sure if we can use this API to replace our current usage of moment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/user-story Used for issues that describes functionality for our users. quality/debt
Projects
Status: ⚠️ Blocked
Development

Successfully merging a pull request may close this issue.

9 participants