summaryrefslogtreecommitdiff
path: root/libsoup/soup-date.c
diff options
context:
space:
mode:
authorEnrico Tröger <enrico.troeger@uvena.de>2009-04-18 09:33:39 -0400
committerDan Winship <danw@gnome.org>2009-04-18 11:42:12 -0400
commitc098315ca88f305f2e840a8724a26ffb8cd279ef (patch)
tree7ab1490ffd0c7af5b5b175791a535ca6d41b5332 /libsoup/soup-date.c
parent6c6a254585c5463de5666182ae417a11a1fd0975 (diff)
downloadlibsoup-c098315ca88f305f2e840a8724a26ffb8cd279ef.tar.gz
Bug 579055 – SOUP_DATE_RFC2822 not handled in soup_date_to_string()
Diffstat (limited to 'libsoup/soup-date.c')
-rw-r--r--libsoup/soup-date.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/libsoup/soup-date.c b/libsoup/soup-date.c
index ba8efb50..daf2ffe9 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;
}