Commit fc4350ac authored by Frédéric Buclin's avatar Frédéric Buclin

Bug 1046213: datetime_from() generates wrong dates if year < 1901

r=sgreen a=glob
parent ace2e1a2
...@@ -566,10 +566,14 @@ sub datetime_from { ...@@ -566,10 +566,14 @@ sub datetime_from {
return undef if !@time; return undef if !@time;
# strptime() counts years from 1900, and months from 0 (January). # strptime() counts years from 1900, except if they are older than 1901
# We have to fix both values. # in which case it returns the full year (so 1890 -> 1890, but 1984 -> 84,
# and 3790 -> 1890). We make a guess and assume that 1100 <= year < 3000.
$time[5] += 1900 if $time[5] < 1100;
my %args = ( my %args = (
year => $time[5] + 1900, year => $time[5],
# Months start from 0 (January).
month => $time[4] + 1, month => $time[4] + 1,
day => $time[3], day => $time[3],
hour => $time[2], hour => $time[2],
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment