From f4e137ffde417e4b24e71304954a5da47a45b261 Mon Sep 17 00:00:00 2001 From: Dan Scott Date: Mon, 6 Jan 2014 12:22:28 -0500 Subject: [PATCH] Use the 'format.time' OUS to format library hours Sparked by a concern that Ben Shum had over the display of library hours in 24 hour format, I eventually figured out that we could use the Template::Toolkit Date module to format the times according to library preferences. And given that we already have a format.time OUS, let's use it. Signed-off-by: Dan Scott Signed-off-by: Dan Wells --- .../templates/opac/parts/library/hours.tt2 | 38 ++++++++++++------- 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/Open-ILS/src/templates/opac/parts/library/hours.tt2 b/Open-ILS/src/templates/opac/parts/library/hours.tt2 index 37513b1010..823701c7d8 100644 --- a/Open-ILS/src/templates/opac/parts/library/hours.tt2 +++ b/Open-ILS/src/templates/opac/parts/library/hours.tt2 @@ -1,57 +1,67 @@ +[% time_format = ctx.get_org_setting(ctx.library.id, 'format.time'); + + UNLESS time_fmt; + time_format = '%H:%M %p'; + END; + + USE date (format = time_format); + today = date.format(format = '%Y-%d-%b '); + # We need to add "today" to the opening/closing hours for Date input +-%]

[% l('Opening hours') %]

[%- IF ctx.hours.dow_0_open == ctx.hours.dow_0_close; %]
[% l('Monday: closed') %]
[%- ELSE %]
[% - l('Monday: [_1]-[_2]', '' _ ctx.hours.dow_0_open.substr(0, 5) _ '', - '' _ ctx.hours.dow_0_close.substr(0, 5) _ '') -%] + l('Monday: [_1] - [_2]', '' _ date.format(today _ ctx.hours.dow_0_open) _ '', + '' _ date.format(today _ ctx.hours.dow_0_close) _ '') -%]
[%- END %] [%- IF ctx.hours.dow_1_open == ctx.hours.dow_1_close; %]
[% l('Tuesday: closed') %]
[%- ELSE %]
[% - l('Tuesday: [_1]-[_2]', '' _ ctx.hours.dow_1_open.substr(0, 5) _ '', - '' _ ctx.hours.dow_1_close.substr(0, 5) _ '') -%] + l('Tuesday: [_1] - [_2]', '' _ date.format(today _ ctx.hours.dow_1_open) _ '', + '' _ date.format(today _ ctx.hours.dow_1_close) _ '') -%]
[%- END %] [%- IF ctx.hours.dow_2_open == ctx.hours.dow_2_close; %]
[% l('Wednesday: closed') %]
[%- ELSE %]
[% - l('Wednesday: [_1]-[_2]', '' _ ctx.hours.dow_2_open.substr(0, 5) _ '', - '' _ ctx.hours.dow_2_close.substr(0, 5) _ '') -%] + l('Wednesday: [_1] - [_2]', '' _ date.format(today _ ctx.hours.dow_2_open) _ '', + '' _ date.format(today _ ctx.hours.dow_2_close) _ '') -%]
[%- END %] [%- IF ctx.hours.dow_3_open == ctx.hours.dow_3_close; %]
[% l('Thursday: closed') %]
[%- ELSE %]
[% - l('Thursday: [_1]-[_2]', '' _ ctx.hours.dow_3_open.substr(0, 5) _ '', - '' _ ctx.hours.dow_3_close.substr(0, 5) _ '') -%] + l('Thursday: [_1] - [_2]', '' _ date.format(today _ ctx.hours.dow_3_open) _ '', + '' _ date.format(today _ ctx.hours.dow_3_close) _ '') -%]
[%- END %] [%- IF ctx.hours.dow_4_open == ctx.hours.dow_4_close; %]
[% l('Friday: closed') %]
[%- ELSE %]
[% - l('Friday: [_1]-[_2]', '' _ ctx.hours.dow_4_open.substr(0, 5) _ '', - '' _ ctx.hours.dow_4_close.substr(0, 5) _ '') -%] + l('Friday: [_1] - [_2]', '' _ date.format(today _ ctx.hours.dow_4_open) _ '', + '' _ date.format(today _ ctx.hours.dow_4_close) _ '') -%]
[%- END %] [%- IF ctx.hours.dow_5_open == ctx.hours.dow_5_close; %]
[% l('Saturday: closed') %]
[%- ELSE %]
[% - l('Saturday: [_1]-[_2]', '' _ ctx.hours.dow_5_open.substr(0, 5) _ '', - '' _ ctx.hours.dow_5_close.substr(0, 5) _ '') -%] + l('Saturday: [_1] - [_2]', '' _ date.format(today _ ctx.hours.dow_5_open) _ '', + '' _ date.format(today _ ctx.hours.dow_5_close) _ '') -%]
[%- END %] [%- IF ctx.hours.dow_6_open == ctx.hours.dow_6_close; %]
[% l('Sunday: closed') %]
[%- ELSE %]
[% - l('Sunday: [_1]-[_2]', '' _ ctx.hours.dow_6_open.substr(0, 5) _ '', - '' _ ctx.hours.dow_6_close.substr(0, 5) _ '') -%] + l('Sunday: [_1] - [_2]', '' _ date.format(today _ ctx.hours.dow_6_open) _ '', + '' _ date.format(today _ ctx.hours.dow_6_close) _ '') -%]
[%- END %] -- 2.43.2