]> mj.ucw.cz Git - libucw.git/blobdiff - ucw/xtypes-test.c
Tests: xtypes-test sets an explicit timezone
[libucw.git] / ucw / xtypes-test.c
index a43e0fb1e28588f70df7bb604733c6a6d0fc4152..b8cbe32a6df6a9a96c100160fea8d78511fa7e0a 100644 (file)
@@ -13,8 +13,9 @@
 #include <ucw/xtypes-extra.h>
 
 #include <errno.h>
-#include <stdlib.h>
 #include <inttypes.h>
+#include <stdlib.h>
+#include <time.h>
 
 static void test_size_parse_correct(struct fastbuf *out)
 {
@@ -134,9 +135,17 @@ static void test_timestamp_parse_correct(struct fastbuf *out)
 
   static u64 timestamp_parsed[] = {
     1403685533,
-    1403678333,
+    0,
   };
 
+  // fill the value of timestamp_parsed as the timestamp in the
+  // current time zone.
+  {
+    struct tm parsed_time;
+    strptime(timestamp_strs[1], "%F %T", &parsed_time);
+    timestamp_parsed[1] = mktime(&parsed_time);
+  }
+
   struct mempool *pool = mp_new(4096);
   uint i = 0;
 
@@ -193,6 +202,7 @@ static void test_timestamp_parse_errors(struct fastbuf *out)
 
 int main(void)
 {
+  setenv("TZ", "Europe/Prague", 1);
   struct fastbuf *out;
   out = bfdopen_shared(1, 4096);