@@ -, +, @@
strings
This function parses a date string, as produced by an api call, and returns the corresponding date formatted according to 'dateformat' and 'TimeFormat' parameters.
For example:
// dateformat: us
// timeformat: 12hr
// Timezone: UTC
$date('2020-03-23T15:00:00+01:00') // You will get '03/23/2020'
$date('2020-03-23T15:00:00+01:00', {withtime: true}) // You will get '03/23/2020 14:00'
$date('2020-03-23T15:00:00+01:00', {withtime: true, tz: 'Europe/Paris'}) // You will get '03/23/2020 15:00+01:00'
Options:
* dateformat: override date format as configured in staff interface (accepts also 'rfc3339')
* timeformat: override time format as configured in staff client (available options are '12hr' and '24hr')
* withtime: also print the time part (default false)
* tz: set the timezone
The same as $date but sets withtime to true
The same as $datetime but shows only the time part
---
Koha/Template/Plugin/KohaDates.pm | 5 ++
.../prog/en/includes/js-date-format.inc | 62 +++++++++++++++++++
.../bootstrap/en/includes/js-date-format.inc | 62 +++++++++++++++++++
3 files changed, 129 insertions(+)
create mode 100644 koha-tmpl/intranet-tmpl/prog/en/includes/js-date-format.inc
create mode 100644 koha-tmpl/opac-tmpl/bootstrap/en/includes/js-date-format.inc
--- a/Koha/Template/Plugin/KohaDates.pm
+++ a/Koha/Template/Plugin/KohaDates.pm
@@ -23,6 +23,7 @@ use Template::Plugin::Filter;
use base qw( Template::Plugin::Filter );
use Koha::DateUtils;
+use C4::Context;
our $DYNAMIC = 1;
sub filter {
@@ -42,4 +43,8 @@ sub output_preference {
return output_pref( @params );
}
+sub tz {
+ return C4::Context->tz->name;
+}
+
1;
--- a/koha-tmpl/intranet-tmpl/prog/en/includes/js-date-format.inc
+++ a/koha-tmpl/intranet-tmpl/prog/en/includes/js-date-format.inc
@@ -0,0 +1,62 @@
+[% USE Koha %]
+[% 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 %]
+
--- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/js-date-format.inc
+++ a/koha-tmpl/opac-tmpl/bootstrap/en/includes/js-date-format.inc
@@ -0,0 +1,62 @@
+[% USE Koha %]
+[% 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 %]
+
--