diff options
author | michaeln@chromium.org <michaeln@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-27 02:43:20 +0000 |
---|---|---|
committer | michaeln@chromium.org <michaeln@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-27 02:43:20 +0000 |
commit | e2419084a9f703f8f1a754ab38b4fcfd61e08225 (patch) | |
tree | 7d6ffa10a2e712898fb7e874ddcf899fef74c1a4 /base | |
parent | 1ea7c844992d80d402b98f2fcc37d4be7121920d (diff) | |
download | chromium_src-e2419084a9f703f8f1a754ab38b4fcfd61e08225.zip chromium_src-e2419084a9f703f8f1a754ab38b4fcfd61e08225.tar.gz chromium_src-e2419084a9f703f8f1a754ab38b4fcfd61e08225.tar.bz2 |
Fix a bug with parsing ftp directory listing lines.
BUG=49997
TEST=ftp_directory_listing_parser_windows_unittest.cc
Review URL: http://codereview.chromium.org/3013029
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@53747 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base')
-rw-r--r-- | base/time.cc | 16 | ||||
-rw-r--r-- | base/time.h | 5 |
2 files changed, 21 insertions, 0 deletions
diff --git a/base/time.cc b/base/time.cc index 2c40d21..a274056 100644 --- a/base/time.cc +++ b/base/time.cc @@ -105,4 +105,20 @@ bool Time::FromString(const wchar_t* time_string, Time* parsed_time) { return true; } +// Time::Exploded ------------------------------------------------------------- + +inline bool is_in_range(int value, int lo, int hi) { + return lo <= value && value <= hi; +} + +bool Time::Exploded::HasValidValues() const { + return is_in_range(month, 1, 12) && + is_in_range(day_of_week, 0, 6) && + is_in_range(day_of_month, 1, 31) && + is_in_range(hour, 0, 23) && + is_in_range(minute, 0, 59) && + is_in_range(second, 0, 60) && + is_in_range(millisecond, 0, 999); +} + } // namespace base diff --git a/base/time.h b/base/time.h index 8d92e75..e885593 100644 --- a/base/time.h +++ b/base/time.h @@ -214,6 +214,11 @@ class Time { int second; // Second within the current minute (0-59 plus leap // seconds which may take it up to 60). int millisecond; // Milliseconds within the current second (0-999) + + // A cursory test for whether the data members are within their + // respective ranges. A 'true' return value does not guarantee the + // Exploded value can be successfully converted to a Time value. + bool HasValidValues() const; }; // Contains the NULL time. Use Time::Now() to get the current time. |