On Mon, 22 Jan 2007 20:38:47 -0600
Nate Bargmann <[EMAIL PROTECTED]> wrote:

[...]

> Is this a bug or does the import function not touch the date format as
> it seems to do when importing from TLF format?
>

You are right ;-)
xlog didn't touch the date...

> I prefer using the Cabrillo format when available as I seem to get a
> cleaner log (with RST + zone, etc.), plus it may be the only way to
> import some old CT logs these days.  Having to fix the date on a
> moderately large log doesn't sound like much fun!  ;-)
> 

The attached patch fixes the date field when doing cabrillo import.

One more question:
Do the other fields look okay? I noticed cabrillo import uses different
field widths depending on the type of contest (see 'CONTEST:' field in
the cabrillo file).
'CONTEST: NA' and 'CONTEST: ARRL-SS' are recognized by xlog, what does
your log say?

I noticed fields get garbled when doing a cabrillo import from tlf when
'CONTEST:' is other then 'NA' or 'ARRL-SS', but I don't know if tlf
follows the right cabrillo format....


> 73, de Nate >>
> 
> -- 
>  Wireless | Amateur Radio Station N0NB          |  Successfully Microsoft
>   Amateur radio exams; ham radio; Linux info @  | free since January 1998.
>              http://www.qsl.net/n0nb/           |  "Debian, the choice of
>              My Kawasaki KZ-650 SR @            |     a GNU generation!"
>         http://www.networksplus.net/n0nb/       |   http://www.debian.org
> 
> 

Regards,
Joop PG4I
--- ../xlog-1.4/src/logfile/cabrillo.c	2006-11-29 17:13:48.000000000 +0100
+++ src/logfile/cabrillo.c	2007-01-23 10:15:17.000000000 +0100
@@ -1,6 +1,6 @@
 /*
  * xlog - GTK+ logging program for amateur radio operators
- * Copyright (C) 2001 - 2006 Joop Stakenborg <[EMAIL PROTECTED]>
+ * Copyright (C) 2001 - 2007 Joop Stakenborg <[EMAIL PROTECTED]>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -26,10 +26,19 @@
  */
 
 #include <stdlib.h>
-#include <string.h>
 #include <stdio.h>
+#include <string.h>
+#include <locale.h>
+#ifndef __USE_XOPEN
+#define __USE_XOPEN
+#endif
+#include <time.h>
 #include <glib.h>
-#include <ctype.h>
+
+#ifndef HAVE_STRPTIME
+#include "strptime.h"
+#define strptime(s,f,t) mystrptime(s,f,t)
+#endif
 
 #include "logfile.h"
 #include "preferences.h"
@@ -241,10 +250,11 @@
 	FILE *fp = (FILE *) handle->priv;
 	gint i, ret;
 	qso_t q[QSO_FIELDS];
-	gchar *field, *end, buffer[MAXROWLEN];
+	gchar *field, *end, buffer[MAXROWLEN], buf[20], *res = NULL;
 	enum cbr_contest_type contest_type = CBR_OTHER;
 	const gint *widths = cabrillo_widths;
 	gint sent_call_len = 14;
+	struct tm tm_cab;
 
 	while (!feof (fp))
 	{
@@ -291,7 +301,23 @@
 
 			end = field + widths[i];
 			*end = '\0';
-			q[cabrillo_fields[i]] = g_strdup (g_strstrip (field));
+
+			/* reformat date 2007-01-23 -> 23 Jan 2007 */
+			if (i == 2)
+			{
+				res = strptime (field, "%Y-%m-%d", &tm_cab);
+				if (res != NULL)
+				{
+					setlocale (LC_TIME, "");
+					strftime (buf, 20, "%d %b %Y", &tm_cab);
+					setlocale (LC_TIME, "C");
+				}
+				else
+					strcpy (buf, field);
+				q[cabrillo_fields[i]] = g_strdup (g_strstrip (buf));
+			}
+			else
+				q[cabrillo_fields[i]] = g_strdup (g_strstrip (field));
 			field = end + 1;
 		}
 
_______________________________________________
Xlog-discussion mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/xlog-discussion

Reply via email to