summaryrefslogtreecommitdiffstats
path: root/base/time.h
diff options
context:
space:
mode:
authorpauljensen@chromium.org <pauljensen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-29 22:54:58 +0000
committerpauljensen@chromium.org <pauljensen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-29 22:54:58 +0000
commit6e6acc10590856575a4c4c330197e828917dc995 (patch)
tree9ef1ac70dcf7723188a3d08222ce98d1933e1b1b /base/time.h
parente42285a3b4def2770cc3ad504a0d73d2d565a313 (diff)
downloadchromium_src-6e6acc10590856575a4c4c330197e828917dc995.zip
chromium_src-6e6acc10590856575a4c4c330197e828917dc995.tar.gz
chromium_src-6e6acc10590856575a4c4c330197e828917dc995.tar.bz2
Default to GMT when parsing HTTP "Date", "Expires" and "Last-Modified" headers.
BUG=153759 TEST=net_unittests --gtest_filter=HttpResponseHeadersTest.DefaultDateToGMT Review URL: https://chromiumcodereview.appspot.com/11269011 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@164762 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/time.h')
-rw-r--r--base/time.h22
1 files changed, 20 insertions, 2 deletions
diff --git a/base/time.h b/base/time.h
index e33cb75..78d7456 100644
--- a/base/time.h
+++ b/base/time.h
@@ -355,10 +355,17 @@ class BASE_EXPORT Time {
// Converts a string representation of time to a Time object.
// An example of a time string which is converted is as below:-
// "Tue, 15 Nov 1994 12:45:26 GMT". If the timezone is not specified
- // in the input string, we assume local time.
+ // in the input string, FromString assumes local time and FromUTCString
+ // assumes UTC. A timezone that cannot be parsed (e.g. "UTC" which is not
+ // specified in RFC822) is treated as if the timezone is not specified.
// TODO(iyengar) Move the FromString/FromTimeT/ToTimeT/FromFileTime to
// a new time converter class.
- static bool FromString(const char* time_string, Time* parsed_time);
+ static bool FromString(const char* time_string, Time* parsed_time) {
+ return FromStringInternal(time_string, true, parsed_time);
+ }
+ static bool FromUTCString(const char* time_string, Time* parsed_time) {
+ return FromStringInternal(time_string, false, parsed_time);
+ }
// For serializing, use FromInternalValue to reconstitute. Please don't use
// this and do arithmetic on it, as it is more error prone than using the
@@ -442,6 +449,17 @@ class BASE_EXPORT Time {
// |is_local = true| or UTC |is_local = false|.
static Time FromExploded(bool is_local, const Exploded& exploded);
+ // Converts a string representation of time to a Time object.
+ // An example of a time string which is converted is as below:-
+ // "Tue, 15 Nov 1994 12:45:26 GMT". If the timezone is not specified
+ // in the input string, local time |is_local = true| or
+ // UTC |is_local = false| is assumed. A timezone that cannot be parsed
+ // (e.g. "UTC" which is not specified in RFC822) is treated as if the
+ // timezone is not specified.
+ static bool FromStringInternal(const char* time_string,
+ bool is_local,
+ Time* parsed_time);
+
// The representation of Jan 1, 1970 UTC in microseconds since the
// platform-dependent epoch.
static const int64 kTimeTToMicrosecondsOffset;