From 1ad0bcbf2b5ffdb2a73d08e26b6c95457d3d99bc Mon Sep 17 00:00:00 2001 From: erickson Date: Wed, 23 Sep 2009 16:22:43 +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/trunk@14118 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- .../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 50cfb4b791..8320ed826f 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Circ/Circulate.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Circ/Circulate.pm @@ -1604,16 +1604,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.43.2