diff options
Diffstat (limited to 'base/time.cc')
-rw-r--r-- | base/time.cc | 16 |
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 |