Skip to content

Comparison takes long on dates over 2036 #90

@markov2

Description

@markov2

When you use a date after 2036, the DateTime::_compare() gets called very often. This is best visible when the year is very large. The program below which makes 100,000 calls to _compare. It does behave timely without time_zone parameter.

#!/usr/bin/perl
  
use strict;
use warnings;

use DateTime;
use Time::HiRes qw(time);

my $dt1 = DateTime->new(year => 9999, month => 1, day => 1);
my $dt2 = DateTime->new(year => 2019, month => 5, day => 28, time_zone => 'Europe/London');

my $start  = time;
my $x = $dt1 < $dt2 ? $dt1 : $dt2;

my $elapse = sprintf "%dms", (time - $start)*1000;
warn "$elapse: $x\n";

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions