diff options
author | John Mark Bell <jmb@netsurf-browser.org> | 2006-02-06 00:10:09 +0000 |
---|---|---|
committer | John Mark Bell <jmb@netsurf-browser.org> | 2006-02-06 00:10:09 +0000 |
commit | 0f228ada91a9460d1042b1a854fb1a0a32ed3f10 (patch) | |
tree | b8279b6c948d3c5d5b3cb470434b2dc6c85fbca4 /utils/utils.c | |
parent | c176e276e2de15a306872e3d4fa74193178eaadf (diff) | |
download | netsurf-0f228ada91a9460d1042b1a854fb1a0a32ed3f10.tar.gz netsurf-0f228ada91a9460d1042b1a854fb1a0a32ed3f10.tar.bz2 |
[project @ 2006-02-06 00:10:09 by jmb]
Implement HTTP caching algorithm; this should avoid stale cache entries being used.
svn path=/import/netsurf/; revision=2059
Diffstat (limited to 'utils/utils.c')
-rw-r--r-- | utils/utils.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/utils/utils.c b/utils/utils.c index 0632b2318..d2cab2aa5 100644 --- a/utils/utils.c +++ b/utils/utils.c @@ -268,3 +268,26 @@ char *human_friendly_bytesize(unsigned long bsize) { return curbuffer; } + +/** + * Create an RFC 1123 compliant date string from a Unix timestamp + * + * \param t The timestamp to consider + * \return Pointer to buffer containing string - invalidated by next call. + */ +const char *rfc1123_date(time_t t) +{ + static char ret[30]; + + struct tm *tm = gmtime(&t); + const char *days[] = { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" }, + *months[] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", + "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }; + + snprintf(ret, sizeof ret, "%s, %02d %s %d %02d:%02d:%02d GMT", + days[tm->tm_wday], tm->tm_mday, months[tm->tm_mon], + tm->tm_year + 1900, tm->tm_hour, tm->tm_min, + tm->tm_sec); + + return ret; +} |