Index: base/time/time_posix.cc |
diff --git a/base/time/time_posix.cc b/base/time/time_posix.cc |
index 32614bc086d2e015782470f851e76573c07e5065..f91d3416972d32d463678b701ace0a09ece5adff 100644 |
--- a/base/time/time_posix.cc |
+++ b/base/time/time_posix.cc |
@@ -211,7 +211,7 @@ void Time::Explode(bool is_local, Exploded* exploded) const { |
} |
// static |
-Time Time::FromExploded(bool is_local, const Exploded& exploded) { |
+bool Time::FromExploded(bool is_local, const Exploded& exploded, Time* time) { |
struct tm timestruct; |
timestruct.tm_sec = exploded.second; |
timestruct.tm_min = exploded.minute; |
@@ -301,8 +301,23 @@ Time Time::FromExploded(bool is_local, const Exploded& exploded) { |
} |
// Adjust from Unix (1970) to Windows (1601) epoch. |
- return Time((milliseconds * kMicrosecondsPerMillisecond) + |
- kWindowsEpochDeltaMicroseconds); |
+ base::Time out_time = Time((milliseconds * kMicrosecondsPerMillisecond) + |
+ kWindowsEpochDeltaMicroseconds); |
+ |
+ // If |exploded.day_of_month| is set to 31 on a 28-30 day month, it will |
+ // return the first day of the next month. Thus round-trip the time and |
+ // compare the initial |exploded| with |utc_to_exploded| time. |
+ base::Time::Exploded to_exploded; |
+ if (!is_local) |
+ out_time.UTCExplode(&to_exploded); |
+ else |
+ out_time.LocalExplode(&to_exploded); |
+ |
+ *time = to_exploded != exploded ? Time(0) : out_time; |
+ |
+ // If time is null, return false |
+ // which means time conversion failed |
+ return (*time).is_null() ? false : true; |
mmenke
2016/05/24 16:08:33
See comment in mac file.
maksims (do not use this acc)
2016/05/26 04:38:18
Done.
|
} |
// TimeTicks ------------------------------------------------------------------ |