View | Details | Raw Unified | Return to bug 15261
Collapse All | Expand All

(-)a/C4/Installer/PerlDependencies.pm (-10 lines)
Lines 787-802 our $PERL_DEPS = { Link Here
787
        'required' => '0',
787
        'required' => '0',
788
        'min_ver'  => '0.03',
788
        'min_ver'  => '0.03',
789
    },
789
    },
790
    'Date::Range' => {
791
        'usage'    => 'Compare date range',
792
        'required' => '1',
793
        'min_ver'  => '1.41',
794
    },
795
    'Date::Simple' => {
796
        'usage'    => 'Works with Date::Range',
797
        'required' => '1',
798
        'min_ver'  => '3.03',
799
    }
800
};
790
};
801
791
802
1;
792
1;
(-)a/Koha/DateUtils.pm (-8 / +25 lines)
Lines 18-25 package Koha::DateUtils; Link Here
18
18
19
use Modern::Perl;
19
use Modern::Perl;
20
use DateTime;
20
use DateTime;
21
use Date::Range;
22
use Date::Simple;
23
use C4::Context;
21
use C4::Context;
24
use Carp;
22
use Carp;
25
23
Lines 310-320 sub format_sqldatetime { Link Here
310
sub date_ranges_overlap {
308
sub date_ranges_overlap {
311
    my ($start1, $end1, $start2, $end2) = @_;
309
    my ($start1, $end1, $start2, $end2) = @_;
312
310
313
    my $range1 = Date::Range->new(Date::Simple->new($start1), Date::Simple->new($end1));
311
    $start1 = dt_from_string( $start1, 'iso' );
314
    my $range2 = Date::Range->new(Date::Simple->new($start2), Date::Simple->new($end2));
312
    $end1 = dt_from_string( $end1, 'iso' );
315
313
    $start2 = dt_from_string( $start2, 'iso' );
316
    if ($range1->overlaps($range2)) {
314
    $end2 = dt_from_string( $end2, 'iso' );
317
        return $range1->overlap($range2);
315
316
    if (
317
        # Start of range 2 is in the range 1.
318
        (
319
            DateTime->compare($start2, $start1) >= 0
320
            && DateTime->compare($start2, $end1) <= 0
321
        )
322
        ||
323
        # End of range 2 is in the range 1.
324
        (
325
            DateTime->compare($end2, $start1) >= 0
326
            && DateTime->compare($end2, $end1) <= 0
327
        )
328
        ||
329
        # Range 2 start before and end after range 1.
330
        (
331
            DateTime->compare($start2, $start1) < 0
332
            && DateTime->compare($end2, $end1) > 0
333
        )
334
    ) {
335
        return 1;
318
    }
336
    }
319
337
320
    return;
338
    return;
321
- 

Return to bug 15261