Blame SOURCES/0205-include-grub-datetime.h-grub_datetime2unixtime-Fix-u.patch

f96e0b
From 9024078c32dd74ba0e376d422cba33f587f7756d Mon Sep 17 00:00:00 2001
f96e0b
From: Vladimir 'phcoder' Serbinenko <phcoder@gmail.com>
f96e0b
Date: Sun, 10 Mar 2013 19:19:21 +0100
f96e0b
Subject: [PATCH 205/482] 	* include/grub/datetime.h
f96e0b
 (grub_datetime2unixtime): Fix unixtime 	computation for some years
f96e0b
 before epoch. Avode confusing division 	while on it.
f96e0b
f96e0b
---
f96e0b
 ChangeLog               | 6 ++++++
f96e0b
 include/grub/datetime.h | 4 +---
f96e0b
 2 files changed, 7 insertions(+), 3 deletions(-)
f96e0b
f96e0b
diff --git a/ChangeLog b/ChangeLog
f96e0b
index 48ca30e..8814c22 100644
f96e0b
--- a/ChangeLog
f96e0b
+++ b/ChangeLog
f96e0b
@@ -1,5 +1,11 @@
f96e0b
 2013-03-10  Vladimir Serbinenko  <phcoder@gmail.com>
f96e0b
 
f96e0b
+	* include/grub/datetime.h (grub_datetime2unixtime): Fix unixtime
f96e0b
+	computation for some years before epoch. Avode confusing division
f96e0b
+	while on it.
f96e0b
+
f96e0b
+2013-03-10  Vladimir Serbinenko  <phcoder@gmail.com>
f96e0b
+
f96e0b
 	* grub-core/video/i386/pc/vbe.c
f96e0b
 	(grub_video_vbe_print_adapter_specific_info): Replace division by
f96e0b
 	shifts.
f96e0b
diff --git a/include/grub/datetime.h b/include/grub/datetime.h
f96e0b
index 3a3b3d0..fef2814 100644
f96e0b
--- a/include/grub/datetime.h
f96e0b
+++ b/include/grub/datetime.h
f96e0b
@@ -89,9 +89,7 @@ grub_datetime2unixtime (const struct grub_datetime *datetime, grub_int32_t *nix)
f96e0b
   ret = 3 * SECPERYEAR + SECPERDAY;
f96e0b
 
f96e0b
   /* Transform C divisions and modulos to mathematical ones */
f96e0b
-  y4 = (datetime->year - 1973) / 4;
f96e0b
-  if (datetime->year < 1973)
f96e0b
-    y4--;
f96e0b
+  y4 = ((datetime->year - 1) >> 2) - (1973 / 4);
f96e0b
   ay = datetime->year - 1973 - 4 * y4;
f96e0b
   ret += y4 * SECPER4YEARS;
f96e0b
   ret += ay * SECPERYEAR;
f96e0b
-- 
f96e0b
1.8.2.1
f96e0b