[libsoup] Bug 579055 – SOUP_DATE_RFC2822 not handled in soup_date_to_string()
- From: Dan Winship <danw src gnome org>
- To: svn-commits-list gnome org
- Subject: [libsoup] Bug 579055 – SOUP_DATE_RFC2822 not handled in soup_date_to_string()
- Date: Sat, 18 Apr 2009 11:46:19 -0400 (EDT)
commit c098315ca88f305f2e840a8724a26ffb8cd279ef
Author: Enrico Tröger <enrico troeger uvena de>
Date: Sat Apr 18 09:33:39 2009 -0400
Bug 579055 â?? SOUP_DATE_RFC2822 not handled in soup_date_to_string()
---
libsoup/soup-date.c | 19 +++++++++++++++----
tests/date.c | 4 +---
2 files changed, 16 insertions(+), 7 deletions(-)
diff --git a/libsoup/soup-date.c b/libsoup/soup-date.c
index ba8efb5..daf2ffe 100644
--- a/libsoup/soup-date.c
+++ b/libsoup/soup-date.c
@@ -298,9 +298,10 @@ parse_timezone (SoupDate *date, const char **date_string)
gulong val;
int sign = (**date_string == '+') ? -1 : 1;
val = strtoul (*date_string + 1, (char **)date_string, 10);
- if (**date_string != ':')
- return FALSE;
- val = 60 * val + strtoul (*date_string + 1, (char **)date_string, 10);
+ if (**date_string == ':')
+ val = 60 * val + strtoul (*date_string + 1, (char **)date_string, 10);
+ else
+ val = 60 * (val / 100) + (val % 100);
date->offset = sign * val;
date->utc = sign && !val;
} else if (**date_string == 'Z') {
@@ -526,7 +527,17 @@ soup_date_to_string (SoupDate *date, SoupDateFormat format)
return g_strdup_printf ("%04d%02d%02dT%02d:%02d:%02d",
date->year, date->month, date->day,
date->hour, date->minute, date->second);
-
+ case SOUP_DATE_RFC2822:
+ {
+ int hour_offset = abs (date->offset) / 60;
+ /* "Sun, 6 Nov 1994 09:49:37 -0100" */
+ return g_strdup_printf ("%s, %d %s %04d %02d:%02d:%02d %c%02d%02d",
+ soup_date_weekday (date), date->day,
+ months[date->month - 1],
+ date->year, date->hour, date->minute,
+ date->second, (date->offset > 0) ? '-' : '+',
+ hour_offset, abs (date->offset) - (hour_offset * 60));
+ }
default:
return NULL;
}
diff --git a/tests/date.c b/tests/date.c
index c19fcef..49afa9f 100644
--- a/tests/date.c
+++ b/tests/date.c
@@ -17,9 +17,7 @@ static const struct {
} good_dates[] = {
{ SOUP_DATE_HTTP, "Sat, 06 Nov 2004 08:09:07 GMT" },
{ SOUP_DATE_COOKIE, "Sat, 06-Nov-2004 08:09:07 GMT" },
-#ifdef NOT_YET
- { SOUP_DATE_RFC2822, "Sat, 06 Nov 2004 08:09:07 +0000" },
-#endif
+ { SOUP_DATE_RFC2822, "Sat, 6 Nov 2004 08:09:07 -0430" },
{ SOUP_DATE_ISO8601_COMPACT, "20041106T080907" },
{ SOUP_DATE_ISO8601_FULL, "2004-11-06T08:09:07" },
{ SOUP_DATE_ISO8601_XMLRPC, "20041106T08:09:07" }
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]