diff --git a/ChangeLog b/ChangeLog index 48ca30ee2..8814c2279 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2013-03-10 Vladimir Serbinenko + + * include/grub/datetime.h (grub_datetime2unixtime): Fix unixtime + computation for some years before epoch. Avode confusing division + while on it. + 2013-03-10 Vladimir Serbinenko * grub-core/video/i386/pc/vbe.c diff --git a/include/grub/datetime.h b/include/grub/datetime.h index 3a3b3d0c3..fef281404 100644 --- a/include/grub/datetime.h +++ b/include/grub/datetime.h @@ -89,9 +89,7 @@ grub_datetime2unixtime (const struct grub_datetime *datetime, grub_int32_t *nix) ret = 3 * SECPERYEAR + SECPERDAY; /* Transform C divisions and modulos to mathematical ones */ - y4 = (datetime->year - 1973) / 4; - if (datetime->year < 1973) - y4--; + y4 = ((datetime->year - 1) >> 2) - (1973 / 4); ay = datetime->year - 1973 - 4 * y4; ret += y4 * SECPER4YEARS; ret += ay * SECPERYEAR;