From 984461b72ba82ebc3802b9951de43b3c8e2e2a37 Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Tue, 6 Nov 2012 14:00:06 -0500 Subject: [PATCH] [SIGNED-OFF]Bug 9014 - Add time due to slips Signed-off-by: Srikanth Dhondi --- C4/Members.pm | 4 ++-- Koha/DateUtils.pm | 19 +++++++++++-------- installer/data/mysql/sysprefs.sql | 1 + installer/data/mysql/updatedatabase.pl | 7 +++++++ .../en/modules/admin/preferences/i18n_l10n.pref | 8 ++++++++ 5 files changed, 29 insertions(+), 10 deletions(-) diff --git a/C4/Members.pm b/C4/Members.pm index b2f45b9..2abb2cb 100644 --- a/C4/Members.pm +++ b/C4/Members.pm @@ -2281,8 +2281,8 @@ sub IssueSlip { elsif ((substr $it->{'date_due'}, 0, 10) le $now) { $it->{'overdue'} = 1; } - - $it->{'date_due'}=format_date($it->{'date_due'}); + my $dt = dt_from_string( $it->{'date_due'} ); + $it->{'date_due'} = output_pref( $dt );; } my @issues = sort { $b->{'timestamp'} <=> $a->{'timestamp'} } @$issueslist; diff --git a/Koha/DateUtils.pm b/Koha/DateUtils.pm index 4ffc160..bb25027 100644 --- a/Koha/DateUtils.pm +++ b/Koha/DateUtils.pm @@ -115,26 +115,29 @@ sub output_pref { my $pref = defined $force_pref ? $force_pref : C4::Context->preference('dateformat'); + given ($pref) { when (/^iso/) { return $dateonly - ? $dt->strftime('%Y-%m-%d') - : $dt->strftime('%Y-%m-%d %H:%M'); + ? $dt->strftime("%Y-%m-%d") + : $dt->strftime("%Y-%m-%d %H:%M"); } when (/^metric/) { return $dateonly - ? $dt->strftime('%d/%m/%Y') - : $dt->strftime('%d/%m/%Y %H:%M'); + ? $dt->strftime("%d/%m/%Y") + : $dt->strftime("%d/%m/%Y %H:%M"); } when (/^us/) { + my $time = ( C4::Context->preference('TimeFormat') eq '12hr' ) ? '%I:%M %p' : '%H:%M'; + return $dateonly - ? $dt->strftime('%m/%d/%Y') - : $dt->strftime('%m/%d/%Y %H:%M'); + ? $dt->strftime("%m/%d/%Y") + : $dt->strftime("%m/%d/%Y $time"); } default { return $dateonly - ? $dt->strftime('%Y-%m-%d') - : $dt->strftime('%Y-%m-%d %H:%M'); + ? $dt->strftime("%Y-%m-%d") + : $dt->strftime("%Y-%m-%d %H:%M"); } } diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql index a4e4102..a60192f 100644 --- a/installer/data/mysql/sysprefs.sql +++ b/installer/data/mysql/sysprefs.sql @@ -386,3 +386,4 @@ INSERT INTO systempreferences (variable,value,explanation,type) VALUES('OPACdidy INSERT INTO systempreferences (variable,value,explanation,type) VALUES('INTRAdidyoumean',NULL,'Did you mean? configuration for the Intranet. Do not change, as this is controlled by /cgi-bin/koha/admin/didyoumean.pl.','Free'); INSERT INTO systempreferences (variable, value, options, explanation, type) VALUES ('BlockReturnOfWithdrawnItems', '1', '0', 'If enabled, items that are marked as withdrawn cannot be returned.', 'YesNo'); INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('HoldsToPullStartDate','2','Set the default start date for the Holds to pull list to this many days ago',NULL,'Integer'); +INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES ('TimeFormat','24hr','12hr|24hr','Defines the global time format for visual output.','Choice'); diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index 518f23a..0e41783 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -6055,6 +6055,13 @@ if (C4::Context->preference("Version") < TransformToNum($DBversion)) { SetVersion ($DBversion); } +$DBversion = "3.09.00.XXX"; +if (C4::Context->preference("Version") < TransformToNum($DBversion)) { + $dbh->do("INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES ('TimeFormat','24hr','12hr|24hr','Defines the global time format for visual output.','Choice')"); + print "Upgrade to $DBversion done (Add syspref TimeFormat)\n"; + SetVersion ($DBversion); +} + =head1 FUNCTIONS =head2 TableExists($table) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/i18n_l10n.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/i18n_l10n.pref index 02b8de6..e24f807 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/i18n_l10n.pref +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/i18n_l10n.pref @@ -9,6 +9,14 @@ I18N/L10N: iso: yyyy-mm-dd - . - + - Format times sing + - pref: TimeFormat + default: us + choices: + 24hr: 24 hour format + 12hr: 12 hour format + - . + - - Use - pref: CalendarFirstDayOfWeek default: Sunday -- 1.7.9.5