[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

MiNTlib pl46: UTC vs. local time



If you want to set your hardware clock to UTC, f.ex. to ease the
coordination with other OS's like Linux, here are patches to the MiNT
library to treat the time from GEMDOS as UTC instead of local time.


--- localtim.c~	Tue Jul 19 18:53:08 1994
+++ localtim.c	Tue Jul 19 19:30:08 1994
@@ -62,6 +62,7 @@
 
 time_t
-mktime(t)
+_mktime(t, local)
         const struct tm *t;
+	int local;
 {
         time_t s;
@@ -80,4 +81,7 @@
 		((t->tm_year - 69)/4)*SECS_PER_DAY;
 
+	if (!local)
+	  return s;
+
 /* Now adjust for the time zone and possible daylight savings time */
 /* note that we have to call tzset() every time; see 1003.1 sect 8.1.1 */
@@ -91,4 +95,10 @@
 }
 
+time_t
+mktime (t)
+     const struct tm *t;
+{
+  return _mktime (t, 1);
+}
 
 struct tm *_gmtime(t, stm)
--- time.c~	Sun Sep  6 05:01:24 1992
+++ time.c	Sat Apr 23 11:26:26 1994
@@ -6,12 +6,7 @@
 #include "lib.h"
 
-static struct tm this_tm;
-int _dst;
-
 /* unixtime: convert a DOS time/date pair into a unix time */
-/* in case people were wondering about whether or not DST is applicable
- * right now, we set the external variable _dst to the value
- * returned from mktime
- */
+
+__EXTERN time_t _mktime __PROTO ((struct tm *, int));
 
 time_t 
@@ -20,4 +15,5 @@
 {
 	time_t t;
+	struct tm this_tm;
 	struct tm *stm = &this_tm;
 
@@ -31,8 +27,5 @@
 	stm->tm_wday = stm->tm_yday = -1; /* or about these */
 
-/* mktime expects a local time, which is what we're giving it */
-	t = mktime(stm);
-
-	_dst = (stm->tm_isdst == 1) ? 1 : 0;
+	t = _mktime(stm, 0);
 	return t;
 }
--- timeoday.c~	Wed Jul  7 02:39:46 1993
+++ timeoday.c	Sat Apr 23 11:30:58 1994
@@ -49,9 +49,11 @@
 {
 	long t = time((time_t *)0);
+	struct tm *local;
 
+	local = localtime (&t);
 	tp->time = t;
 	tp->millitm = 0;
 	tp->timezone = (int)(_timezone / 60);
-	tp->dstflag = (_dst) ? 1 : 0;
+	tp->dstflag = local->tm_isdst;
 
 	return 0;
--- utime.c~	Tue Mar 14 01:11:20 1995
+++ utime.c	Tue Mar 14 01:30:10 1995
@@ -42,5 +42,5 @@
 	struct tm *ctm;
 
-	if ((ctm = localtime(&t)) == NULL)
+	if ((ctm = gmtime(&t)) == NULL)
 		return 0;
 	time = (ctm->tm_hour << 11) | (ctm->tm_min << 5) | (ctm->tm_sec >> 1);