From 058ada4e69862641c9bdc8af110b9644b85d1505 Mon Sep 17 00:00:00 2001 From: erickson Date: Wed, 23 Sep 2009 16:23:38 +0000 Subject: [PATCH] represent due date in local time zone (eventually org unit time zone). cleaned up the due-date calculation code git-svn-id: svn://svn.open-ils.org/ILS/branches/rel_1_6_0@14120 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- .../src/perlmods/OpenILS/Application/Circ/Circulate.pm | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Circ/Circulate.pm b/Open-ILS/src/perlmods/OpenILS/Application/Circ/Circulate.pm index 586c240e03..0fc3974e4e 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Circ/Circulate.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Circ/Circulate.pm @@ -1499,16 +1499,19 @@ sub apply_modified_due_date { sub create_due_date { my( $self, $duration ) = @_; + # if there is a raw time component (e.g. from postgres), # turn it into an interval that interval_to_seconds can parse $duration =~ s/(\d{2}):(\d{2}):(\d{2})/$1 h $2 m $3 s/o; - my ($sec,$min,$hour,$mday,$mon,$year) = - gmtime(OpenSRF::Utils->interval_to_seconds($duration) + int(time())); - $year += 1900; $mon += 1; - my $due_date = sprintf( - '%s-%0.2d-%0.2dT%0.2d:%0.2d:%0.2d-00', - $year, $mon, $mday, $hour, $min, $sec); - return $due_date; + + # for now, use the server timezone. TODO: use workstation org timezone + my $due_date = DateTime->now(time_zone => 'local'); + + # add the circ duration + $due_date->add(seconds => OpenSRF::Utils->interval_to_seconds($duration)); + + # return ISO8601 time with timezone + return $due_date->strftime('%FT%T%z'); } -- 2.11.0