Bugzilla – Attachment 145099 Details for
Bug 30310
Replace Moment.js with Day.js
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 30310: Adjust js-date-format
Bug-30310-Adjust-js-date-format.patch (text/plain), 4.42 KB, created by
Kyle M Hall (khall)
on 2023-01-06 19:38:49 UTC
(
hide
)
Description:
Bug 30310: Adjust js-date-format
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2023-01-06 19:38:49 UTC
Size:
4.42 KB
patch
obsolete
>From e9308332256a194e6b0edad032598d84241decd7 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Tue, 31 May 2022 15:09:43 +0200 >Subject: [PATCH] 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> >--- > .../prog/en/includes/js-date-format.inc | 20 +++++++++++----- > .../bootstrap/en/includes/js-date-format.inc | 24 +++++++++++++------ > 2 files changed, 31 insertions(+), 13 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/js-date-format.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/js-date-format.inc >index 6b302166c9..f8bff29d8f 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/js-date-format.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/js-date-format.inc >@@ -2,8 +2,14 @@ > [% USE raw %] > [% USE Asset %] > [% USE KohaDates %] >-[% Asset.js("lib/moment/moment.min.js") | $raw %] >-[% Asset.js("lib/moment/moment-timezone-with-data-10-year-range.min.js") | $raw %] >+[% Asset.js("lib/dayjs/dayjs.min.js") | $raw %] >+[% Asset.js("lib/dayjs/plugin/timezone.js") | $raw %] >+[% Asset.js("lib/dayjs/plugin/utc.js") | $raw %] >+<script> >+ dayjs.extend(window.dayjs_plugin_utc); >+ dayjs.extend(window.dayjs_plugin_timezone); >+</script> >+ > <!-- js-date-format.inc --> > <script> > (function() { >@@ -34,8 +40,10 @@ > window.$date = function(value, options) { > if(!value) return ''; > var tz = (options&&options.tz)||def_tz; >- var m = moment(value); >- if((m.creationData().format !== 'YYYY-MM-DD')&&tz) m.tz(tz); >+ var m = dayjs(value); >+ if ( ! value.match(/^\d{4}-\d{2}-\d{2}$/ ) ) { >+ m = m.tz(tz); >+ } > > var dateformat = (options&&options.dateformat)||def_date_format; > var withtime = (options&&options.withtime)||false; >@@ -58,8 +66,8 @@ > window.$time = function(value, options) { > if(!value) return ''; > var tz = (options&&options.tz)||def_tz; >- var m = moment(value); >- if(tz) m.tz(tz); >+ var m = dayjs(value); >+ if(tz) m = m.tz(tz); > > var dateformat = (options&&options.dateformat); > var timeformat = (dateformat=='rfc3339'&&'24hr')||(options&&options.timeformat)||def_time_format; >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/includes/js-date-format.inc b/koha-tmpl/opac-tmpl/bootstrap/en/includes/js-date-format.inc >index 643cda065b..4f6b08db6d 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/js-date-format.inc >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/js-date-format.inc >@@ -2,8 +2,15 @@ > [% USE raw %] > [% USE Asset %] > [% USE KohaDates %] >-[% Asset.js("lib/moment.min.js") | $raw %] >-[% Asset.js("lib/moment-timezone-with-data-10-year-range.min.js") | $raw %] >+[% Asset.js("lib/dayjs/dayjs.min.js") | $raw %] >+[% Asset.js("lib/dayjs/plugin/timezone.js") | $raw %] >+[% Asset.js("lib/dayjs/plugin/utc.js") | $raw %] >+<script> >+ dayjs.extend(window.dayjs_plugin_utc); >+ dayjs.extend(window.dayjs_plugin_timezone); >+</script> >+ >+<!-- js-date-format.inc --> > <script> > (function() { > var def_date_format = '[% Koha.Preference('dateformat') | html %]'; >@@ -33,8 +40,10 @@ > window.$date = function(value, options) { > if(!value) return ''; > var tz = (options&&options.tz)||def_tz; >- var m = moment(value); >- if((m.creationData().format !== 'YYYY-MM-DD')&&tz) m.tz(tz); >+ var m = dayjs(value); >+ if ( ! value.match(/^\d{4}-\d{2}-\d{2}$/ ) ) { >+ m = m.tz(tz); >+ } > > var dateformat = (options&&options.dateformat)||def_date_format; > var withtime = (options&&options.withtime)||false; >@@ -56,9 +65,9 @@ > > window.$time = function(value, options) { > if(!value) return ''; >- var tz = (opitons&&options.tz)||def_tz; >- var m = moment(value); >- if(tz) m.tz(tz); >+ var tz = (options&&options.tz)||def_tz; >+ var m = dayjs(value); >+ if(tz) m = m.tz(tz); > > var dateformat = (options&&options.dateformat); > var timeformat = (dateformat=='rfc3339'&&'24hr')||(options&&options.timeformat)||def_time_format; >@@ -68,3 +77,4 @@ > > })(); > </script> >+<!-- / js-date-format.inc --> >-- >2.30.2
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 30310
:
135495
|
135496
|
135497
|
135498
|
135499
|
136507
|
136508
|
136509
|
136510
|
136511
|
137676
|
137677
|
137678
|
137679
|
141859
|
141860
|
141861
|
141862
|
143172
|
143173
|
144948
|
144950
|
144995
|
144996
|
144997
|
144998
|
144999
|
145000
|
145001
|
145097
|
145098
| 145099 |
145100
|
145101
|
145102
|
145103
|
145104