As noted in comments #15, #16 and #17 of bug 8486, and its API, 
Koha::Calendar->days_between
should always returns a positive number irrespective of the relative order of 
the parameters.
This is still an open bug, which arised when rewriting the Calendar.t file (Bug 
9209).

Regards
To+

Sponsored-by: Universidad Nacional de Córdoba
---
 Koha/Calendar.pm |    7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/Koha/Calendar.pm b/Koha/Calendar.pm
index 45841be..6a12530 100644
--- a/Koha/Calendar.pm
+++ b/Koha/Calendar.pm
@@ -247,6 +247,13 @@ sub days_between {
     my $start_dt = shift;
     my $end_dt   = shift;
 
+    if ( $start_dt->compare($end_dt) > 0 ) {
+        # swap dates
+        my $int_dt = $end_dt;
+        $end_dt = $start_dt;
+        $start_dt = $int_dt;
+    }
+
 
     # start and end should not be closed days
     my $days = $start_dt->delta_days($end_dt)->delta_days;
-- 
1.7.10.4

_______________________________________________
Koha-patches mailing list
[email protected]
http://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-patches
website : http://www.koha-community.org/
git : http://git.koha-community.org/
bugs : http://bugs.koha-community.org/

Reply via email to