Bugzilla – Attachment 99061 Details for
Bug 24650
API returned timestamps are incompatible with existing helpers
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 24650: Convert ISO datetimes to syspref dates
Bug-24650-Convert-ISO-datetimes-to-syspref-dates.patch (text/plain), 2.04 KB, created by
David Nind
on 2020-02-15 10:58:39 UTC
(
hide
)
Description:
Bug 24650: Convert ISO datetimes to syspref dates
Filename:
MIME Type:
Creator:
David Nind
Created:
2020-02-15 10:58:39 UTC
Size:
2.04 KB
patch
obsolete
>From 89791181bb8ba5e3248cb19fd6dba09a632309ab Mon Sep 17 00:00:00 2001 >From: Andrew Isherwood <andrew.isherwood@ptfs-europe.com> >Date: Thu, 13 Feb 2020 12:25:31 +0000 >Subject: [PATCH] Bug 24650: Convert ISO datetimes to syspref dates > >This patch adds a function 'ISO_to_syspref' that accepts an ISO8601 / RFC3339 formatted timestamp, as returned >from the API for datetime DB columns, and returns a string formatted >according to the 'dateformat' syspref, optionally including the time > >Test plan: >- Apply the patch >- Load a page that uses calendar.inc, for example a patron's loan list >in the staff interface >- In the JS console, type the following and notice the printed date is >in the format according to the syspref: > >var dt = new Date; >console.log(ISO_to_syspref(dt.toISOString())); > >- In the JS console, type the following and notice the printed date is >in the format according to the syspref, and includes the time: > >console.log(ISO_to_syspref(dt.toISOString(), true)); > >Signed-off-by: David Nind <david@davidnind.com> >--- > koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc | 10 ++++++++++ > 1 file changed, 10 insertions(+) > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc >index 1cd41e2961..a41ccf7d0e 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc >@@ -99,6 +99,16 @@ function DateTime_from_syspref(date_time) { > return datetime; > } > >+function ISO_to_syspref(date_time, include_time) { >+ var dt = new Date(Date.parse(date_time)); >+ var dateFormat = get_dateformat_str('[% Koha.Preference('dateformat') | html %]'); >+ dateFormat = dateFormat.replace('yyyy', 'yy'); >+ var ret = $.datepicker.formatDate(dateFormat, dt); >+ if (include_time) { >+ ret += ' ' + dt.getHours() + ':' + dt.getMinutes(); >+ } >+ return ret; >+} > > /* Instead of including multiple localization files as you would normally see with > jQueryUI we expose the localization strings in the default configuration */ >-- >2.11.0
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 24650
:
98818
| 99061