Subject: | For "huge" dates, from_epoch with time_zone = "local" takes forever and eats a lot of memory. |
A code that does
from_epoch(epoch => $date, time_zone => "local")
when $date is _way_ in the future, takes enormous time and memory.
Here is a code snippet that demonstrates the problem:
#!/usr/bin/perl
use DateTime;
system("ps u $$");
$start = time();
$dt = DateTime->from_epoch(epoch => 569151104400, time_zone => "local");
$end = time();
system("ps u $$");
print "It took ", $end - $start, "seconds \n";
On my machine (DateTime 0.28, perl v5.8.3 built for x86_64-linux-thread-multi, Fedora Core 2 on 2.2Ghz Athlon _64_) the above reports spending ~2min in the from_epoch call and the process size grows by about 185MB.
P.S. I came across this when the WebWork system ( http://webwork.rochester.edu/ ) became very unresponsive as a result of one professor accidentally entering year 20005 in a due date field. While WebWork should have probably rejected such "due date" (and I will file a WebWork bug report about it), DateTime shouldn't be that resource-hungry on dates in the future.