Bugzilla – Attachment 136509 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
Martin Renvoize (ashimema)
on 2022-06-24 14:49:33 UTC
(
hide
)
Description:
Bug 30310: Adjust js-date-format
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2022-06-24 14:49:33 UTC
Size:
4.42 KB
patch
obsolete
>From d9be9426d74f259a6273108cca89803648031482 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> >--- > .../prog/en/includes/js-date-format.inc | 22 +++++++++++------ > .../bootstrap/en/includes/js-date-format.inc | 24 +++++++++++++------ > 2 files changed, 32 insertions(+), 14 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 3dae094b8d..4f6b08db6d 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; >@@ -57,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; >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.20.1
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