Index: base/time/time.h |
diff --git a/base/time/time.h b/base/time/time.h |
index 9fce71b581e4ca27c216e31cb40ab78b867760ea..ede6ebd6a756d7dc4efa6c0612a1f1f266f7539d 100644 |
--- a/base/time/time.h |
+++ b/base/time/time.h |
@@ -420,6 +420,7 @@ class BASE_EXPORT Time : public time_internal::TimeBase<Time> { |
// respective ranges. A 'true' return value does not guarantee the |
// Exploded value can be successfully converted to a Time value. |
bool HasValidValues() const; |
+ bool operator!=(const Exploded& rhs); |
}; |
// Contains the NULL time. Use Time::Now() to get the current time. |
@@ -522,6 +523,20 @@ class BASE_EXPORT Time : public time_internal::TimeBase<Time> { |
return FromExploded(true, exploded); |
} |
+ // Converts an exploded structure representing either the local time or UTC |
+ // into a Time class. |
+ // This is a transition to a new format, where the converted time is set to |
+ // |time| and FromUTCExploded, FromLocalExploded and FromExploded return true |
+ // on success or false on failure. For example, FromExploded can fail when |
+ // 31st of a month is set on a 28-30 day month, which results in 1st day of |
+ // the next month. |
+ static bool FromUTCExploded(const Exploded& exploded, Time& time) { |
mmenke
2016/05/20 19:44:56
Per Google C++ style guide, non-const refs are for
maksims (do not use this acc)
2016/05/24 09:14:21
Done.
|
+ return FromExploded(false, exploded, time); |
+ } |
+ static bool FromLocalExploded(const Exploded& exploded, Time& time) { |
mmenke
2016/05/20 19:44:56
These two should use WARN_UNUSED_RESULT.
maksims (do not use this acc)
2016/05/24 09:14:21
Done.
|
+ return FromExploded(true, exploded, time); |
+ } |
mmenke
2016/05/20 19:44:56
Is the plan to replace calls to the old methods wi
maksims (do not use this acc)
2016/05/24 09:14:21
Yes, I would like to do so.
|
+ |
// Converts a string representation of time to a Time object. |
// An example of a time string which is converted is as below:- |
// "Tue, 15 Nov 1994 12:45:26 GMT". If the timezone is not specified |
@@ -563,6 +578,13 @@ class BASE_EXPORT Time : public time_internal::TimeBase<Time> { |
// |is_local = true| or UTC |is_local = false|. |
static Time FromExploded(bool is_local, const Exploded& exploded); |
mmenke
2016/05/20 19:44:56
If we're going to keep the old methods around (Per
maksims (do not use this acc)
2016/05/24 09:14:21
Done.
|
+ // Unexplodes a given time assuming the source is either local time |
+ // |is_local = true| or UTC |is_local = false|. |
+ // This is a transition to a newer form. Function returns false on failure |
+ // and sets |time| to Time(0). Otherwise returns true and sets |time| to |
+ // non-exploded time. |
+ static bool FromExploded(bool is_local, const Exploded& exploded, Time& time); |
mmenke
2016/05/20 19:44:56
WARN_UNUSED_RESULT
maksims (do not use this acc)
2016/05/24 09:14:21
Done.
|
+ |
// Converts a string representation of time to a Time object. |
// An example of a time string which is converted is as below:- |
// "Tue, 15 Nov 1994 12:45:26 GMT". If the timezone is not specified |