summaryrefslogtreecommitdiffstats
path: root/base/time.cc
diff options
context:
space:
mode:
authormichaeln@chromium.org <michaeln@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-27 02:43:20 +0000
committermichaeln@chromium.org <michaeln@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-27 02:43:20 +0000
commite2419084a9f703f8f1a754ab38b4fcfd61e08225 (patch)
tree7d6ffa10a2e712898fb7e874ddcf899fef74c1a4 /base/time.cc
parent1ea7c844992d80d402b98f2fcc37d4be7121920d (diff)
downloadchromium_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/time.cc')
-rw-r--r--base/time.cc16
1 files changed, 16 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