]> git.proxmox.com Git - pve-common.git/commit
fix #1682: handle relative years absolutely
authorFabian Grünbichler <f.gruenbichler@proxmox.com>
Wed, 28 Feb 2018 09:42:56 +0000 (10:42 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Wed, 7 Mar 2018 10:35:28 +0000 (11:35 +0100)
commit7c5eeae56a3c05a0562efb62accf5c69058b8736
treeb076464319279b69061b5a58693a222ae357ac4d
parentc44ec0f66358b956d70f8f61acf58a9e43780744
fix #1682: handle relative years absolutely

the timegm(gmtime()) and timelocal(localtime(()) constructs are
problematic in the following case: - $last is such that $year gets set
to a two-digit value (e.g., the referred to timestamp is somewhere in
the range of 1900-1999) - the current date is such that the value of
$year gets interpreted wrongly (e.g., anything other than 1950).

the exact breakage depends on the actual current date AND value of
$last, since localtime/gmtime will interpret two-digit years as (perldoc
Time::Local):
    [...] shorthand for years in the rolling "current century," defined
    as 50 years on either side of the current year. Thus, today, in
    1999, 0 would refer to 2000, and 45 to 2045, but 55 would refer to
    1955.  Twenty years from now, 55 would instead refer to 2055.

fix it by adding 1900 to force 4-digit $year values, as the localtime
documentation suggests.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
src/PVE/CalendarEvent.pm