From: Vladimir 'phcoder' Serbinenko Date: Wed, 26 Oct 2011 17:27:36 +0000 (+0200) Subject: * include/grub/datetime.h (grub_datetime2unixtime): Fix off-by-one X-Git-Tag: 2.00~1055 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=186b402804c37ff3fda5b2a969d071a978194195;p=thirdparty%2Fgrub.git * include/grub/datetime.h (grub_datetime2unixtime): Fix off-by-one error. --- diff --git a/ChangeLog b/ChangeLog index 9787d8f9e..084131202 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,9 @@ -2011-10-25 Vladimir Serbinenko +2011-10-26 Vladimir Serbinenko + + * include/grub/datetime.h (grub_datetime2unixtime): Fix off-by-one + error. + +2011-10-26 Vladimir Serbinenko ZFS fixes. diff --git a/include/grub/datetime.h b/include/grub/datetime.h index dea0f8ea9..049dbc227 100644 --- a/include/grub/datetime.h +++ b/include/grub/datetime.h @@ -86,13 +86,13 @@ grub_datetime2unixtime (const struct grub_datetime *datetime, grub_int32_t *nix) are bissextile*/ /* Convenience: let's have 3 consecutive non-bissextile years at the beginning of the epoch. So count from 1971 instead of 1970 */ - ret = SECPERYEAR + SECPERDAY; + ret = 2 * SECPERYEAR + SECPERDAY; /* Transform C divisions and modulos to mathematical ones */ - y4 = (datetime->year - 1971) / 4; - if (datetime->year < 1971) + y4 = (datetime->year - 1972) / 4; + if (datetime->year < 1972) y4--; - ay = datetime->year - 1971 - 4 * y4; + ay = datetime->year - 1972 - 4 * y4; ret += y4 * SECPER4YEARS; ret += ay * SECPERYEAR;