keep the original due_date time component of day-granular circs on due_date edit
authormiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 3 Mar 2010 19:36:11 +0000 (19:36 +0000)
committermiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 3 Mar 2010 19:36:11 +0000 (19:36 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@15680 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/perlmods/OpenILS/Application/Circ.pm

index 7d71984..a06404d 100644 (file)
@@ -490,6 +490,13 @@ sub set_circ_due_date {
 
     return $e->die_event unless $e->allowed('CIRC_OVERRIDE_DUE_DATE', $circ->circ_lib);
        $date = cleanse_ISO8601($date);
+
+    if (!(interval_to_seconds($circ->duration) % 86400)) { # duration is divisible by days
+        my $original_date = DateTime::Format::ISO8601->new->parse_datetime(cleanse_ISO8601($circ->due_date));
+        my $new_date = DateTime::Format::ISO8601->new->parse_datetime($date);
+        $date = $new_date->ymd . 'T' . $original_date->strftime('%T%z');
+    }
+
        $circ->due_date($date);
     $e->update_action_circulation($circ) or return $e->die_event;
     $e->commit;