New subdirectory bin.
[gedcom-parse.git] / t / src / gom_write.c
index cb28844aa81f08b5d96dda6f885c992a27015f6d..4bfeac5c5a93486074cab8b37cbc8a8da9049105 100644 (file)
@@ -31,6 +31,7 @@
 #define WRITE_GEDCOM "gom_write.ged"
 #define PROG_NAME "writegomtest"
 #define PROG_VERSION "3.14"
+#define TIMESTAMP 1000000000L
 
 void gedcom_message_handler(Gedcom_msg_type type, char *msg)
 {
@@ -72,13 +73,12 @@ int update_header(char* encoding)
   if (head == NULL)
     return 1;
   else {
-    /*
-    value = gom_set_string(&head->charset.name, encoding);
-    if (value == NULL || strcmp(value, encoding))
-      return 1;
-    else
-      return 0;
-    */
+    /* force warning for anything except UNICODE */
+    if (!strcmp(encoding, "UNICODE")) {
+      value = gom_set_string(&head->charset.name, encoding);
+      if (value == NULL || strcmp(value, encoding))
+       return 1;
+    }
     value = gom_set_string(&head->note, long_note);
     if (value == NULL || strcmp(value, long_note))
       return 1;
@@ -90,6 +90,8 @@ int update_header(char* encoding)
 int main(int argc, char* argv[])
 {
   int result;
+  struct tm* tm_ptr;
+  time_t tval;
   int total_conv_fails = 0;
   char* outfilename = NULL;
   char* infilename  = NULL;
@@ -223,6 +225,14 @@ int main(int argc, char* argv[])
     if (result == 0)
       result |= update_header(encoding);
   }
+  /* Make sure we get a reproduceable output, in different timezones */
+  if (result == 0) {
+    tval   = TIMESTAMP;
+    tm_ptr = gmtime(&tval);
+    tm_ptr->tm_isdst = 0;
+    tval   = mktime(tm_ptr);
+    result = gom_header_update_timestamp(tval);
+  }
   if (result == 0)
     result |= gom_write_file(gedfilename, &total_conv_fails);
   if (result == 0 && total_conv_fails == 0) {