changeset 33:d3b7d4964807

Create a TZ info structure for ACST and use it when printing times.
author Daniel O'Connor <darius@dons.net.au>
date Tue, 27 Nov 2012 15:56:31 +1030
parents 188d5a8a7470
children 07589f738e5e
files syscalls.c tempctrl.c
diffstat 2 files changed, 16 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/syscalls.c	Tue Nov 27 15:56:09 2012 +1030
+++ b/syscalls.c	Tue Nov 27 15:56:31 2012 +1030
@@ -147,11 +147,26 @@
 __tz_unlock (void) {
 }
 
+/* Set tzinfo directly so we don't need tzset() which requires getenv() */
+#ifdef USE_UTC
 static __tzinfo_type tzinfo = {1, 0,
     { {'J', 0, 0, 0, 0, (time_t)0, 0L },
       {'J', 0, 0, 0, 0, (time_t)0, 0L } 
     } 
 };
+#else
+/* ACST (south)
+ * Switch from DST 3am 1st Sunday of April:  -9.5 hours to UTC
+ * Switch  to  DST 2am 1st Sunday October:  -10.5 hours to UTC
+ *
+ * Copied from http://www.sourceware.org/ml/newlib/2008/msg00311.html
+ */
+static __tzinfo_type tzinfo = {0, 0, {
+	{'M',  4, 5, 0, 10800, (time_t)0, -37800L },
+	{'M', 10, 5, 0,  7200, (time_t)0, -34200L } 
+    }
+};
+#endif
 
 __tzinfo_type *
 __gettzinfo (void) {
--- a/tempctrl.c	Tue Nov 27 15:56:09 2012 +1030
+++ b/tempctrl.c	Tue Nov 27 15:56:31 2012 +1030
@@ -272,7 +272,7 @@
 	currstate = nextstate;
 
     
-    gmtime_r(&t, &tm);
+    localtime_r(&t, &tm);
     assert(strftime(buf, sizeof(buf) - 1, "%Y/%m/%d %H:%M:%S: ", &tm) != 0);
     fputs(buf, stdout);
     printtemp("Tr", settings.target_temp, ", ");