Bug 30310

Summary: Replace Moment.js with Day.js
Product: Koha Reporter: Jonathan Druart <jonathan.druart+koha>
Component: Architecture, internals, and plumbingAssignee: Jonathan Druart <jonathan.druart+koha>
Status: Signed Off --- QA Contact: Katrin Fischer <katrin.fischer>
Severity: enhancement    
Priority: P5 - low CC: lucas, m.de.rooy, martin.renvoize, nick, tomascohen
Version: unspecified   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: Small patch
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Bug Depends on: 30718, 24455    
Bug Blocks: 31149    
Attachments: Bug 30310: Add dayjs v1.11.2
Bug 30310: Add dayjs timezone plugin
Bug 30310: Adjust js-date-format
Bug 30310: Remove momentjs
Bug 30310: Adjust about page
Bug 30310: Add dayjs v1.11.2
Bug 30310: Add dayjs timezone plugin
Bug 30310: Adjust js-date-format
Bug 30310: Remove momentjs
Bug 30310: Adjust about page
Bug 30310: Add dayjs timezone plugin
Bug 30310: Adjust js-date-format
Bug 30310: Remove momentjs
Bug 30310: Adjust about page
Bug 30310: Add dayjs timezone plugin
Bug 30310: Adjust js-date-format
Bug 30310: Remove momentjs
Bug 30310: Adjust about page
Bug 30310: Add missing utc plugin
Bug 30310: Add missing utc plugin

Description Jonathan Druart 2022-03-17 15:03:24 UTC
https://github.com/moment/moment
Moment.js is a legacy project, now in maintenance mode. In most cases, you should choose a different library.

Day.js looks like a good replacement.
https://day.js.org/
Comment 1 Jonathan Druart 2022-05-31 13:14:14 UTC
Created attachment 135495 [details] [review]
Bug 30310: Add dayjs v1.11.2
Comment 2 Jonathan Druart 2022-05-31 13:14:18 UTC
Created attachment 135496 [details] [review]
Bug 30310: Add dayjs timezone plugin
Comment 3 Jonathan Druart 2022-05-31 13:14:22 UTC
Created attachment 135497 [details] [review]
Bug 30310: Adjust js-date-format

Test plan:
Confirm that the test plan from bug 24455 is still passing
Comment 4 Jonathan Druart 2022-05-31 13:14:27 UTC
Created attachment 135498 [details] [review]
Bug 30310: Remove momentjs
Comment 5 Jonathan Druart 2022-05-31 13:14:32 UTC
Created attachment 135499 [details] [review]
Bug 30310: Adjust about page
Comment 6 Martin Renvoize 2022-06-24 14:49:24 UTC
Created attachment 136507 [details] [review]
Bug 30310: Add dayjs v1.11.2

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 7 Martin Renvoize 2022-06-24 14:49:28 UTC
Created attachment 136508 [details] [review]
Bug 30310: Add dayjs timezone plugin

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 8 Martin Renvoize 2022-06-24 14:49:33 UTC
Created attachment 136509 [details] [review]
Bug 30310: Adjust js-date-format

Test plan:
Confirm that the test plan from bug 24455 is still passing

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 9 Martin Renvoize 2022-06-24 14:49:37 UTC
Created attachment 136510 [details] [review]
Bug 30310: Remove momentjs

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 10 Martin Renvoize 2022-06-24 14:49:42 UTC
Created attachment 136511 [details] [review]
Bug 30310: Adjust about page

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 11 Martin Renvoize 2022-06-24 14:51:03 UTC
No regressions found in my testing.. passing to QA
Comment 12 Jonathan Druart 2022-07-06 14:40:14 UTC
I think I found a bug, it's not working if you modify dateformat. See also https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=137212
Comment 13 Jonathan Druart 2022-07-13 06:59:39 UTC
Created attachment 137676 [details] [review]
Bug 30310: Add dayjs timezone plugin

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 14 Jonathan Druart 2022-07-13 06:59:44 UTC
Created attachment 137677 [details] [review]
Bug 30310: Adjust js-date-format

Test plan:
Confirm that the test plan from bug 24455 is still passing

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 15 Jonathan Druart 2022-07-13 06:59:48 UTC
Created attachment 137678 [details] [review]
Bug 30310: Remove momentjs

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 16 Jonathan Druart 2022-07-13 06:59:53 UTC
Created attachment 137679 [details] [review]
Bug 30310: Adjust about page

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 17 Nick Clemens 2022-08-19 11:52:38 UTC
After applying my console has an error:
Uncaught TypeError: t is undefined ... dayjs.min_22.0600035.js:1:6455
Comment 18 Katrin Fischer 2022-10-02 22:41:59 UTC
(In reply to Nick Clemens from comment #17)
> After applying my console has an error:
> Uncaught TypeError: t is undefined ... dayjs.min_22.0600035.js:1:6455

I tested on Tools > Calendar. In Firefox I have the same error. In Chromium I see:

dayjs.min_22.0600054.js:1 Uncaught TypeError: Cannot read properties of undefined (reading '$i')
Comment 19 Jonathan Druart 2022-10-14 07:41:05 UTC
Hum, I don't recreate, but maybe was it a conflict with bug 30718? Can you try again now that 30718 has been pushed to master?
Comment 20 Jonathan Druart 2022-10-14 07:41:44 UTC
Created attachment 141859 [details] [review]
Bug 30310: Add dayjs timezone plugin

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 21 Jonathan Druart 2022-10-14 07:41:50 UTC
Created attachment 141860 [details] [review]
Bug 30310: Adjust js-date-format

Test plan:
Confirm that the test plan from bug 24455 is still passing

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 22 Jonathan Druart 2022-10-14 07:41:56 UTC
Created attachment 141861 [details] [review]
Bug 30310: Remove momentjs

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 23 Jonathan Druart 2022-10-14 07:42:02 UTC
Created attachment 141862 [details] [review]
Bug 30310: Adjust about page

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 24 Katrin Fischer 2022-10-30 11:43:45 UTC
(In reply to Katrin Fischer from comment #18)
> (In reply to Nick Clemens from comment #17)
> > After applying my console has an error:
> > Uncaught TypeError: t is undefined ... dayjs.min_22.0600035.js:1:6455
> 
> I tested on Tools > Calendar. In Firefox I have the same error. In Chromium
> I see:
> 
> dayjs.min_22.0600054.js:1 Uncaught TypeError: Cannot read properties of
> undefined (reading '$i')

I am sorry, the issue remains for me. Applied patches, restart_all. Tested in a private tab also.

Firefox:
Uncaught TypeError: t is undefined

Chromium:
dayjs.min_22.0600075.js:1 Uncaught TypeError: Cannot read properties of undefined (reading '$i')
Comment 25 Jonathan Druart 2022-10-31 07:02:07 UTC
(In reply to Katrin Fischer from comment #24)
> (In reply to Katrin Fischer from comment #18)
> > (In reply to Nick Clemens from comment #17)
> > > After applying my console has an error:
> > > Uncaught TypeError: t is undefined ... dayjs.min_22.0600035.js:1:6455
> > 
> > I tested on Tools > Calendar. In Firefox I have the same error. In Chromium
> > I see:
> > 
> > dayjs.min_22.0600054.js:1 Uncaught TypeError: Cannot read properties of
> > undefined (reading '$i')
> 
> I am sorry, the issue remains for me. Applied patches, restart_all. Tested
> in a private tab also.
> 
> Firefox:
> Uncaught TypeError: t is undefined
> 
> Chromium:
> dayjs.min_22.0600075.js:1 Uncaught TypeError: Cannot read properties of
> undefined (reading '$i')

How? Please provide the steps. I can go to /cgi-bin/koha/tools/holidays.pl and add new holidays, in a private window.
Comment 26 Jonathan Druart 2022-10-31 07:11:12 UTC
https://staff-bz30310.sandboxes.biblibre.eu
It's working for me there.
Comment 27 Nick Clemens 2022-10-31 10:04:39 UTC
(In reply to Jonathan Druart from comment #26)
> https://staff-bz30310.sandboxes.biblibre.eu
> It's working for me there.

Locally I just apply patches, the error is in the console on every page - I restarted all, cleared cache, tried private window
Comment 28 Katrin Fischer 2022-10-31 10:06:13 UTC
(In reply to Nick Clemens from comment #27)
> (In reply to Jonathan Druart from comment #26)
> > https://staff-bz30310.sandboxes.biblibre.eu
> > It's working for me there.
> 
> Locally I just apply patches, the error is in the console on every page - I
> restarted all, cleared cache, tried private window

Thx Nick, I can confirm I don't see the error on the sandbox, but saw the problem on 2 different occasions in my ktd environment. I am very sure it was reset in between too, but cannot repeat the test right now.
Comment 29 Marcel de Rooy 2022-11-04 09:43:28 UTC
Seeing same warning about Uncaught TypeError: t is undefined
Comment 30 Jonathan Druart 2022-11-04 09:54:51 UTC
Created attachment 143172 [details] [review]
Bug 30310: Add missing utc plugin
Comment 31 Jonathan Druart 2022-11-04 09:55:43 UTC
(In reply to Jonathan Druart from comment #30)
> Created attachment 143172 [details] [review] [review]
> Bug 30310: Add missing utc plugin

Joubu> The following paths are ignored by one of your .gitignore files:
Joubu> koha-tmpl/intranet-tmpl/lib/dayjs/plugin
Joubu> Use -f if you really want to add them.
Joubu> I have one file that is not committed there
Joubu> but it does not appear in git status because "plugin" is in .gitignore
Comment 32 Marcel de Rooy 2022-11-04 09:57:50 UTC
(In reply to Marcel de Rooy from comment #29)
> Seeing same warning about Uncaught TypeError: t is undefined

Last follow-up clears warning for me.
Comment 33 Jonathan Druart 2022-11-04 09:58:58 UTC
Should be good now, sorry!
Comment 34 Jonathan Druart 2022-11-04 10:12:50 UTC
Created attachment 143173 [details] [review]
Bug 30310: Add missing utc plugin