. Beautification: Prettyprint the date
authorJoey Schulze <joey@infodrom.org>
Mon, 17 Dec 2001 21:41:46 +0000 (21:41 +0000)
committerJoey Schulze <joey@infodrom.org>
Mon, 17 Dec 2001 21:41:46 +0000 (21:41 +0000)
 . Bugfix: Properly output Betrag-Euro as Betrag so the generated .ctl
   file can be used as input again, as it schould be.  Thanks to Jan
   Gottschick for reporting this bug.

dtaus.c

diff --git a/dtaus.c b/dtaus.c
index b556ffb..4e73e49 100644 (file)
--- a/dtaus.c
+++ b/dtaus.c
@@ -772,6 +772,45 @@ void printctln(FILE *f, char *field, char *value)
     fprintf(f, "  %s\t%s\n", field, value);
 }
 
+/*
+ * one date line, format it properly
+ */
+void printctlndate(FILE *f, char *field, char *value)
+{
+  char mydate[11];
+
+  if (!strlen(field) || !strlen(value))
+    return;
+
+  memset (mydate, 0, sizeof (mydate));
+  if (strlen (value) == 6) {
+    mydate[0] = value[0];
+    mydate[1] = value[1];
+    mydate[2] = '.';
+    mydate[3] = value[2];
+    mydate[4] = value[3];
+    mydate[5] = '.';
+    mydate[6] = value[4];
+    mydate[7] = value[5];
+    fprintf(f, "  %s\t%s\n", field, mydate);
+  } else if (strlen (value) == 8) {
+    mydate[0] = value[0];
+    mydate[1] = value[1];
+    mydate[2] = '.';
+    mydate[3] = value[2];
+    mydate[4] = value[3];
+    mydate[5] = '.';
+    mydate[6] = value[4];
+    mydate[7] = value[5];
+    mydate[8] = value[6];
+    mydate[9] = value[7];
+    fprintf(f, "  %s\t%s\n", field, mydate);
+  } else {
+    fprintf (stderr, "Broken date field: %s\n", value);
+    fprintf(f, "  %s\t%s\n", field, value);
+  }
+}
+
 
 /*
  *  Third: Some high level routines
@@ -825,7 +864,10 @@ void dtaus2control (char *cdtaus, char *ccontrol)
 #endif
        bufp = buf + recA[index].pos;
        memcpy(tmp, bufp, recA[index].len); tmp[recA[index].len] = '\0';
-       printctln(fcontrol, recA[index].name, strip_zeros(strip_spaces(tmp)));
+       if (index == A_DATE || index == A_TODO)
+         printctlndate(fcontrol, recA[index].name, tmp);
+       else
+         printctln(fcontrol, recA[index].name, strip_zeros(strip_spaces(tmp)));
       }
 
 #ifndef DEFAULT_EURO
@@ -863,10 +905,11 @@ void dtaus2control (char *cdtaus, char *ccontrol)
          bufp = buf + recC[index].pos;
          memcpy(tmp, bufp, recC[index].len); tmp[recC[index].len] = '\0';
 #ifndef DEFAULT_EURO
-         if (index == C_VAL || index == C_EUR)
-#else
-         if (index == C_VAL)
+         if (index == C_EUR)
+           printctln(fcontrol, recC[C_VAL].name, strip_zeros(string2real(tmp)));
+         else
 #endif
+         if (index == C_VAL)
            printctln(fcontrol, recC[index].name, strip_zeros(string2real(tmp)));
          else if (index == C_TRANS)
            printctln(fcontrol, recC[index].name, strip_zeros(string2trans(tmp)));