[open-ils-commits] r14118 - trunk/Open-ILS/src/perlmods/OpenILS/Application/Circ (erickson)

svn at svn.open-ils.org svn at svn.open-ils.org
Wed Sep 23 12:22:46 EDT 2009


Author: erickson
Date: 2009-09-23 12:22:43 -0400 (Wed, 23 Sep 2009)
New Revision: 14118

Modified:
   trunk/Open-ILS/src/perlmods/OpenILS/Application/Circ/Circulate.pm
Log:
represent due date in local time zone (eventually org unit time zone).  cleaned up the due-date calculation code

Modified: trunk/Open-ILS/src/perlmods/OpenILS/Application/Circ/Circulate.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Application/Circ/Circulate.pm	2009-09-23 16:06:41 UTC (rev 14117)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Application/Circ/Circulate.pm	2009-09-23 16:22:43 UTC (rev 14118)
@@ -1604,16 +1604,19 @@
 
 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');
 }
 
 



More information about the open-ils-commits mailing list