From: erickson Date: Mon, 26 Oct 2009 15:15:39 +0000 (+0000) Subject: updated the max_delay_age date math, added comments X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=1711e03d02747332dde3c189a28fcbc679c7460d;p=evergreen%2Fpines.git updated the max_delay_age date math, added comments git-svn-id: svn://svn.open-ils.org/ILS/trunk@14605 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Trigger/Validator.pm b/Open-ILS/src/perlmods/OpenILS/Application/Trigger/Validator.pm index 6efe8c48f5..df50636704 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Trigger/Validator.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Trigger/Validator.pm @@ -26,9 +26,15 @@ sub MaxPassiveDelayAge { my $delay_field = $env->{event}->event_def->delay_field; my $delay_field_ts = DateTime::Format::ISO8601->new->parse_datetime(clense_ISO8601($target->$delay_field())); - $delay_field_ts->add( seconds => interval_to_seconds( $env->{params}->{max_delay_age} ) ); - return 0 if $delay_field_ts > DateTime->now; + # the cutoff date is today - delay - age. This is also true for negative delays. + # For example, today - "7 days" - "1 day" == 8 days ago. For a 7-day delay, you would + # not validate if the date of the object is 8 or more days old. + my $max_date = DateTime->now; + $max_date->subtract( seconds => interval_to_seconds( $env->{event}->event_def->delay ) ); + $max_date->subtract( seconds => interval_to_seconds( $env->{params}->{max_delay_age} ) ); + + return 0 if $delay_field_ts <= $max_date; return 1; }