From bd047bad6e42b7d2798558eeff25f9a73db1e783 Mon Sep 17 00:00:00 2001 From: Dan Wells Date: Fri, 21 Jul 2017 14:28:16 -0400 Subject: [PATCH] LP#1635737 Use new OpenSRF interval_to_seconds() context Use the optional context for interval_to_seconds() to account for the variable length of duration components. For example, "1 day" may be shorter or longer than 24 hours during a time change event, "1 month" may be shorter or longer depending on which month it is currently, etc. Also, remove some timestamp munging, as that happens within interval_to_seconds() already. Signed-off-by: Dan Wells Signed-off-by: Mike Rylander Conflicts: Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Circulate.pm Signed-off-by: Dan Wells Signed-off-by: Bill Erickson --- .../src/perlmods/lib/OpenILS/Application/Circ/Circulate.pm | 6 +----- .../src/perlmods/lib/OpenILS/Application/Circ/NonCat.pm | 2 +- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Circulate.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Circulate.pm index bf5dd0eabf..990c3a75ee 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Circulate.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Circulate.pm @@ -2387,16 +2387,12 @@ sub apply_modified_due_date { sub create_due_date { my( $self, $duration, $date_ceiling, $force_date, $start_time ) = @_; - # 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; - # for now, use the server timezone. TODO: use workstation org timezone my $due_date = DateTime->now(time_zone => 'local'); $due_date = DateTime::Format::ISO8601->new->parse_datetime(clean_ISO8601($start_time)) if $start_time; # add the circ duration - $due_date->add(seconds => OpenILS::Utils::DateTime->interval_to_seconds($duration)); + $due_date->add(seconds => OpenILS::Utils::DateTime->interval_to_seconds($duration, $due_date)); if($date_ceiling) { my $cdate = DateTime::Format::ISO8601->new->parse_datetime(clean_ISO8601($date_ceiling)); diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/NonCat.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/NonCat.pm index 0d576cf5d6..cdf9a6fed7 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/NonCat.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/NonCat.pm @@ -188,7 +188,7 @@ sub noncat_due_date { my $duedate = $_dt_parser->parse_datetime( clean_ISO8601($circ->circ_time) ); $duedate = $duedate - ->add( seconds => interval_to_seconds($otype->circ_duration) ) + ->add( seconds => interval_to_seconds($otype->circ_duration, $duedate) ) ->strftime('%FT%T%z'); my $offset = $U->storagereq( -- 2.43.2