The alternative way to handle this problem, where it makes sense in the
context of the script, is to string compare the ISO outputs from C4::Dates
objects.  (This is a major advantage of the ISO format -- that the string
order is the same as the date order.)

So in cases where you are feeding the dates input/output through C4::Dates
anyway, just create the objects up front and use
$date1->output('iso') cmp $date2->output('iso')
or:
$date1->output('iso') gt $date2->output('iso')

Most if not all of the scripts where this would be helpful are already using
C4::Dates.
--joe

On Thu, Jul 10, 2008 at 2:21 PM, Galen Charlton <[EMAIL PROTECTED]>
wrote:

> From: Jesse Weaver <[EMAIL PROTECTED]>
>
> Modified overdue check in circ/circulation.pl to use Date::Manip's
> Date_Cmp. This would likely be useful other places in the file.
>
> Signed-off-by: Galen Charlton <[EMAIL PROTECTED]>
> ---
>  circ/circulation.pl |    8 +++++---
>  1 files changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/circ/circulation.pl b/circ/circulation.pl
> index 61babaa..b165d68 100755
> --- a/circ/circulation.pl
> +++ b/circ/circulation.pl
> @@ -44,6 +44,10 @@ use Date::Calc qw(
>   Date_to_Days
>  );
>
> +use Date::Manip qw(
> +  Date_Cmp
> +);
> +
>
>  #
>  # PARAMETERS READING
> @@ -450,9 +454,7 @@ if ($borrower) {
>     ($restype) and $it->{'can_renew'} = 0;
>
>     $it->{'dd'} = format_date($it->{'date_due'});
> -        my $datedue = $it->{'date_due'};
> -        $datedue =~ s/-//g;
> -    $it->{'od'} = ($datedue < $todaysdate) ? 1 : 0 ;
> +    $it->{'od'} = Date_Cmp($todaysdate, $it->{'date_due'}) == 1 ? 1 : 0 ;
>         ($it->{'author'} eq '') and $it->{'author'} = ' ';
>         $it->{'renew_failed'} = $renew_failed[$it->{'itemnumber'}];
>         # ADDED BY JF: NEW ITEMTYPE COUNT DISPLAY
> --
> 1.5.5.GIT
>
_______________________________________________
Koha-patches mailing list
[email protected]
http://lists.koha.org/mailman/listinfo/koha-patches

Reply via email to