| Index: base/time/time_posix.cc
|
| diff --git a/base/time/time_posix.cc b/base/time/time_posix.cc
|
| index 32614bc086d2e015782470f851e76573c07e5065..a5986347f939dfefe16183a4a0aedf0984cae138 100644
|
| --- a/base/time/time_posix.cc
|
| +++ b/base/time/time_posix.cc
|
| @@ -1,4 +1,4 @@
|
| -// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
| +// Copyright (c) 2016 The Chromium Authors. All rights reserved.
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| @@ -301,8 +301,21 @@ Time Time::FromExploded(bool is_local, const Exploded& exploded) {
|
| }
|
|
|
| // Adjust from Unix (1970) to Windows (1601) epoch.
|
| - return Time((milliseconds * kMicrosecondsPerMillisecond) +
|
| - kWindowsEpochDeltaMicroseconds);
|
| + base::Time t_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.
|
| + // If they are not same, return Time(0).
|
| + // Windows and Mac implementations return Time(0) on failure.
|
| + base::Time::Exploded to_exploded = {0};
|
| + if (!is_local)
|
| + t_time.UTCExplode(&to_exploded);
|
| + else
|
| + t_time.LocalExplode(&to_exploded);
|
| +
|
| + return to_exploded != exploded ? Time(0) : t_time;
|
| }
|
|
|
| // TimeTicks ------------------------------------------------------------------
|
|
|