From 0d080fd6442290e3160d50f3aa72b08a22fb07b0 Mon Sep 17 00:00:00 2001 From: tgarip1957 Date: Mon, 6 Nov 2006 20:25:43 +0000 Subject: [PATCH] All necessary date functions for koha using the fast DateTime module --- C4/Date.pm | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/C4/Date.pm b/C4/Date.pm index 2d7d710029..513a573dad 100644 --- a/C4/Date.pm +++ b/C4/Date.pm @@ -1,5 +1,5 @@ #!/usr/bin/perl -## written by T Garip 2006-10-10 +## written by T Garip 2006-10-10 tgarip@neu.edu.tr # Copyright 2000-2002 Katipo Communications # # This file is part of Koha. @@ -43,6 +43,7 @@ $VERSION = do { my @v = '$Revision$' =~ /\d+/g; shift(@v) . "." . join( "_", map &get_date_format_string_for_DHTMLcalendar &DATE_diff &DATE_Add &get_today &DATE_Add_Duration &DATE_obj &get_duration +&DATE_subtract ); sub get_date_format { @@ -200,5 +201,13 @@ my $parser=DateTime::Format::Duration->new(pattern => $parse ); my $duration=$parser->parse_duration($period); return $duration; +} +sub DATE_subtract{ +my ($date1,$date2)=@_; +my $dt1=DateTime::Format::ISO8601->parse_datetime($date1); +my $dt2=DateTime::Format::ISO8601->parse_datetime($date2); +my $dur=$dt2->subtract_datetime_absolute($dt1);## in seconds +my $days=$dur->seconds/(60*60*24); +return int($days); } 1; -- 2.39.5