Bug 30310

Summary: Replace Moment.js with Day.js
Product: Koha Reporter: Jonathan Druart <jonathan.druart>
Component: Architecture, internals, and plumbingAssignee: Jonathan Druart <jonathan.druart>
Status: RESOLVED FIXED QA Contact: Kyle M Hall <kyle>
Severity: enhancement    
Priority: P5 - low CC: kyle, 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:
23.05.00,22.11.03
Bug Depends on: 30718, 24455    
Bug Blocks: 31149, 32505, 32559    
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
Bug 30310: Replace one more occurrence to moment
Bug 30310: Fix date_to_rfc3339
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: Replace one more occurrence to moment
Bug 30310: Fix date_to_rfc3339
Bug 30310: Add dayjs timezone plugin
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: Replace one more occurrence to moment
Bug 30310: Fix date_to_rfc3339

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
Comment 35 Martin Renvoize 2022-12-20 12:54:54 UTC
How are we doing here.. nearly PQA?
Comment 36 Jonathan Druart 2023-01-03 12:24:23 UTC
Can this be a candidate for an early push to 23.05 please?
Comment 37 Jonathan Druart 2023-01-03 16:55:20 UTC
Created attachment 144948 [details] [review]
Bug 30310: Replace one more occurrence to moment
Comment 38 Jonathan Druart 2023-01-03 17:18:08 UTC
Created attachment 144950 [details] [review]
Bug 30310: Fix date_to_rfc3339

We need the customParseFormat plugin to provide a custom date format to
the dayjs constructor.
Found while working on bug 32559, don't remove this function, it will be
used later.
Comment 39 Martin Renvoize 2023-01-04 12:07:38 UTC
Created attachment 144995 [details] [review]
Bug 30310: Add dayjs timezone plugin

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 40 Martin Renvoize 2023-01-04 12:07:43 UTC
Created attachment 144996 [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 41 Martin Renvoize 2023-01-04 12:07:48 UTC
Created attachment 144997 [details] [review]
Bug 30310: Remove momentjs

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 42 Martin Renvoize 2023-01-04 12:07:53 UTC
Created attachment 144998 [details] [review]
Bug 30310: Adjust about page

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 43 Martin Renvoize 2023-01-04 12:07:58 UTC
Created attachment 144999 [details] [review]
Bug 30310: Add missing utc plugin

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 44 Martin Renvoize 2023-01-04 12:08:03 UTC
Created attachment 145000 [details] [review]
Bug 30310: Replace one more occurrence to moment

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 45 Martin Renvoize 2023-01-04 12:08:08 UTC
Created attachment 145001 [details] [review]
Bug 30310: Fix date_to_rfc3339

We need the customParseFormat plugin to provide a custom date format to
the dayjs constructor.
Found while working on bug 32559, don't remove this function, it will be
used later.

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 46 Kyle M Hall 2023-01-06 19:27:35 UTC
Created attachment 145097 [details] [review]
Bug 30310: Add dayjs timezone plugin

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Comment 47 Kyle M Hall 2023-01-06 19:38:38 UTC
Created attachment 145098 [details] [review]
Bug 30310: Add dayjs timezone plugin

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Comment 48 Kyle M Hall 2023-01-06 19:38:49 UTC
Created attachment 145099 [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>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Comment 49 Kyle M Hall 2023-01-06 19:38:53 UTC
Created attachment 145100 [details] [review]
Bug 30310: Remove momentjs

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Comment 50 Kyle M Hall 2023-01-06 19:38:57 UTC
Created attachment 145101 [details] [review]
Bug 30310: Adjust about page

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Comment 51 Kyle M Hall 2023-01-06 19:39:02 UTC
Created attachment 145102 [details] [review]
Bug 30310: Add missing utc plugin

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Comment 52 Kyle M Hall 2023-01-06 19:39:07 UTC
Created attachment 145103 [details] [review]
Bug 30310: Replace one more occurrence to moment

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Comment 53 Kyle M Hall 2023-01-06 19:39:11 UTC
Created attachment 145104 [details] [review]
Bug 30310: Fix date_to_rfc3339

We need the customParseFormat plugin to provide a custom date format to
the dayjs constructor.
Found while working on bug 32559, don't remove this function, it will be
used later.

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Comment 54 Tomás Cohen Arazi 2023-01-31 13:23:16 UTC
Pushed to master for 23.05.

Nice work everyone, thanks!
Comment 55 Matt Blenkinsop 2023-02-01 15:44:04 UTC
Nice work everyone!

Pushed to stable for 22.11.x
Comment 56 Lucas Gass 2023-02-03 22:29:26 UTC
22.05.x has the dependencies but I am not sure about backporting this at this point in the 22.05.x lifecycle. 

Won't backport unless convinced otherwise.