public this repo is viewable by everyone
Description: A Clutter-based Twitter client
Clone URL: git://github.com/ebassi/tweet.git
Replace custom date functions with SoupDate

Instead of using our own crude implementations for parsing
and generating HTTP date strings, use libsoup's SoupDate
type which is far more reliable.
Emmanuele Bassi (author)
27 days ago
commit  a643edaaa7ba328cf4f24356dbeb5c2faa5837e3
tree    a002d1ab1d3439fcbbd514ce3b803f4d8e216866
parent  455bcf01d7cb8a5c84630024c693349a9c06dafe
...
50
51
52
53
54
 
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
 
 
 
88
89
90
...
103
104
105
106
107
108
109
110
111
112
113
 
 
 
 
 
 
 
 
114
115
116
...
50
51
52
 
 
53
54
55
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
56
57
58
59
60
61
...
74
75
76
 
 
 
 
 
 
 
 
77
78
79
80
81
82
83
84
85
86
87
0
@@ -50,41 +50,12 @@ twitter_error_quark (void)
0
 gchar *
0
 twitter_http_date_from_time_t (time_t time_)
0
 {
0
- struct tm tmp;
0
- char buffer[256];
0
+ SoupDate *soup_date;
0
   gchar *retval;
0
 
0
-#ifdef HAVE_LOCALTIME_R
0
- localtime_r (&time_, &tmp);
0
-#else
0
- {
0
- struct tm *ptm = localtime (&time_);
0
-
0
- if (ptm == NULL)
0
- {
0
- /* Happens at least in Microsoft's C library if you pass a
0
- * negative time_t. Use 2000-01-01 as default date.
0
- */
0
-# ifndef G_DISABLE_CHECKS
0
- g_return_if_fail_warning (G_LOG_DOMAIN,
0
- "twitter_http_date_from_time_t",
0
- "ptm != NULL");
0
-# endif /* G_DISABLE_CHECKS */
0
-
0
- tmp.tm_mon = 0;
0
- tmp.tm_mday = 1;
0
- tmp.tm_year = 100;
0
- }
0
- else
0
- memcpy ((void *) &tmp, (void *) ptm, sizeof(struct tm));
0
- }
0
-#endif /* HAVE_LOCALTIME_R */
0
-
0
- /* see RFC 1123 */
0
- if (strftime (buffer, sizeof (buffer), "%a, %d %b %Y %T %Z", &tmp) == 0)
0
- return NULL;
0
- else
0
- retval = g_strdup (buffer);
0
+ soup_date = soup_date_new_from_time_t (time_);
0
+ retval = soup_date_to_string (soup_date, SOUP_DATE_HTTP);
0
+ soup_date_free (soup_date);
0
 
0
   return retval;
0
 }
0
@@ -103,14 +74,14 @@ twitter_http_date_from_delta (gint seconds)
0
 time_t
0
 twitter_http_date_to_time_t (const gchar *date)
0
 {
0
-#ifdef HAVE_STRPTIME
0
- struct tm tmp;
0
-
0
- if (strptime (date, "%a, %d %b %Y %T %Z", &tmp) == NULL)
0
- return mktime (&tmp);
0
- else
0
-#endif /* HAVE_STRPTIME */
0
- return time (NULL);
0
+ SoupDate *soup_date;
0
+ time_t retval;
0
+
0
+ soup_date = soup_date_new_from_string (date);
0
+ retval = soup_date_to_time_t (soup_date);
0
+ soup_date_free (soup_date);
0
+
0
+ return retval;
0
 }
0
 
0
 gint

Comments

    No one has commented yet.