[tz] [PATCH] Introduce Epoch offset and local time Epoch

Carsten Larsen cs at innolan.dk
Tue Oct 11 18:16:12 UTC 2016


---
 localtime.c | 22 +++++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)

diff --git a/localtime.c b/localtime.c
index 6c00c45..3465248 100644
--- a/localtime.c
+++ b/localtime.c
@@ -58,6 +58,15 @@ static void unlock(void) { }
 #define OPEN_MODE	O_RDONLY
 #endif /* !defined O_BINARY */
 
+/*
+** AmigaOS Epoch is local time January 1, 1978
+*/
+
+#ifdef AMIGAOS
+#define TZEPOCH_OFFSET -252460800
+#define TZLOCAL_EPOCH 1
+#endif /* defined AMIGAOS */
+
 #ifndef WILDABBR
 /*
 ** Someone might make incorrect use of a time zone abbreviation:
@@ -118,6 +127,12 @@ struct lsinfo {				/* leap second information */
 #ifndef TZNAME_MAX
 #define MY_TZNAME_MAX	255
 #endif /* !defined TZNAME_MAX */
+#ifndef TZEPOCH_OFFSET
+#define TZEPOCH_OFFSET 0
+#endif /* !defined TZEPOCH_OFFSET */
+#ifdef TZLOCAL_EPOCH
+#define ALTZONE 1
+#endif /* defined TZLOCAL_EPOCH */
 
 struct state {
 	int		leapcnt;
@@ -2262,7 +2277,12 @@ posix2time(time_t t)
 time_t
 time(time_t *p)
 {
-  time_t r = sys_time(0);
+  time_t r = sys_time(0) + TZEPOCH_OFFSET;
+#ifdef TZLOCAL_EPOCH
+  if(lcl_is_set) {
+    r += (!daylight ? timezone : altzone);
+  }
+#endif
   if (p)
     *p = r;
   return r;
-- 
2.7.4




More information about the tz mailing list