about summary refs log tree commit diff
path: root/time/tst-mktime.c
diff options
context:
space:
mode:
Diffstat (limited to 'time/tst-mktime.c')
-rw-r--r--time/tst-mktime.c36
1 files changed, 35 insertions, 1 deletions
diff --git a/time/tst-mktime.c b/time/tst-mktime.c
index 70c123c3f9..7ce1d45dd5 100644
--- a/time/tst-mktime.c
+++ b/time/tst-mktime.c
@@ -5,7 +5,8 @@
 int
 main (void)
 {
-  struct tm time_str;
+  struct tm time_str, *tm;
+  time_t t;
   char daybuf[20];
   int result;
 
@@ -29,5 +30,38 @@ main (void)
       result = strcmp (daybuf, "Wednesday") != 0;
     }
 
+  setenv ("TZ", "EST", 1);
+#define EVENING69 1 * 60 * 60 + 2 * 60 + 29
+  t = EVENING69;
+  tm = localtime (&t);
+  if (tm == NULL)
+    {
+      (void) puts ("localtime returned NULL");
+      result = 1;
+    }
+  else
+    {
+      time_str = *tm;
+      t = mktime (&time_str);
+      if (t != EVENING69)
+        {
+          printf ("mktime returned %ld, expected %ld\n",
+		  (long) t, EVENING69);
+	  result = 1;
+        }
+      else
+        (void) puts ("Dec 31 1969 EST test passed");
+
+      setenv ("TZ", "CET", 1);
+      t = mktime (&time_str);
+      if (t != (time_t) -1)
+        {
+	  printf ("mktime returned %ld, expected -1\n", (long) t);
+	  result = 1;
+        }
+      else
+        (void) puts ("Dec 31 1969 CET test passed");
+    }
+
   return result;
 }