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