From 58c6dc0f1481791c028fc61975f3d917c3053d45 Mon Sep 17 00:00:00 2001 From: hiro Date: Fri, 15 Feb 2013 05:11:00 +0000 Subject: Supported more non-standard date. git-svn-id: svn://sylpheed.sraoss.jp/sylpheed/trunk@3229 ee746299-78ed-0310-b773-934348b2243d --- ChangeLog | 1 + libsylph/procheader.c | 20 ++++++++++++++------ 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index e0637c99..f29ca997 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,6 +3,7 @@ * libsylph/procheader.cprocheader_date_parse(): support ISO-type date (YYYY-MM-DD HH:MM:SS). Added workaround for time_t limit. + Supported more non-standard date. 2013-02-15 diff --git a/libsylph/procheader.c b/libsylph/procheader.c index bd635363..ec8667b4 100644 --- a/libsylph/procheader.c +++ b/libsylph/procheader.c @@ -1,6 +1,6 @@ /* * LibSylph -- E-Mail client library - * Copyright (C) 1999-2007 Hiroyuki Yamamoto + * Copyright (C) 1999-2013 Hiroyuki Yamamoto * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -817,6 +817,14 @@ static gint procheader_scan_date_string(const gchar *str, weekday, day, month, year, hh, mm, ss, zone); if (result == 8) return 0; + result = sscanf(str, "%3s,%d %9s %d %2d.%2d.%2d %5s", + weekday, day, month, year, hh, mm, ss, zone); + if (result == 8) return 0; + + result = sscanf(str, "%3s %d, %9s %d %2d:%2d:%2d %5s", + weekday, day, month, year, hh, mm, ss, zone); + if (result == 8) return 0; + result = sscanf(str, "%d %9s %d %2d:%2d:%2d %5s", day, month, year, hh, mm, ss, zone); if (result == 7) return 0; @@ -830,6 +838,10 @@ static gint procheader_scan_date_string(const gchar *str, day, month, year, hh, mm, ss); if (result == 6) return 0; + result = sscanf(str, "%d-%2s-%2d %2d:%2d:%2d", + year, month, day, hh, mm, ss); + if (result == 6) return 0; + *ss = 0; result = sscanf(str, "%10s %d %9s %d %2d:%2d %5s", weekday, day, month, year, hh, mm, zone); @@ -839,11 +851,6 @@ static gint procheader_scan_date_string(const gchar *str, day, month, year, hh, mm, zone); if (result == 6) return 0; - *zone = '\0'; - result = sscanf(str, "%d-%2s-%2d %2d:%2d:%2d", - year, month, day, hh, mm, ss); - if (result == 6) return 0; - result = sscanf(str, "%10s %d %9s %d %2d:%2d", weekday, day, month, year, hh, mm); if (result == 6) return 0; @@ -872,6 +879,7 @@ time_t procheader_date_parse(gchar *dest, const gchar *src, gint len) if (procheader_scan_date_string(src, weekday, &day, month, &year, &hh, &mm, &ss, zone) < 0) { + g_warning("procheader_scan_date_string: date parse failed: %s", src); if (dest && len > 0) strncpy2(dest, src, len); return 0; -- cgit v1.2.3