Chromium Code Reviews| Index: ash/system/night_light/night_light_time.h |
| diff --git a/ash/system/night_light/night_light_time.h b/ash/system/night_light/night_light_time.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..82b51f7f4a2486110c336258955496d1b92a9839 |
| --- /dev/null |
| +++ b/ash/system/night_light/night_light_time.h |
| @@ -0,0 +1,52 @@ |
| +// Copyright 2017 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. |
| + |
| +#ifndef ASH_SYSTEM_NIGHT_LIGHT_NIGHT_LIGHT_TIME_H_ |
| +#define ASH_SYSTEM_NIGHT_LIGHT_NIGHT_LIGHT_TIME_H_ |
|
James Cook
2017/05/23 16:34:59
I think this class should be called TimeOfDay, sin
afakhry
2017/05/24 04:21:11
Done. Eclipse is very good at this! Just Highlight
|
| + |
| +#include <string> |
| + |
| +#include "ash/ash_export.h" |
| +#include "base/time/time.h" |
| + |
| +namespace ash { |
| + |
| +// Represents the time of the day as a simple number of minutes since 00:00 |
| +// regardless of the date or the timezone. This makes it simple to persist this |
| +// as an integer user pref. |
| +class ASH_EXPORT NightLightTime { |
|
James Cook
2017/05/23 16:34:59
Aside: I'm a little surprised we don't already hav
afakhry
2017/05/24 04:21:11
Yes, me too.
|
| + public: |
| + // |offset_minutes| is the number of minutes since 00:00. If |offset_minutes| |
| + // is equal to the offset minutes in 24 hours, it will be reset to 0 to |
| + // represent the time 00:00 (12:00 AM). Offsets greater than the minutes in |
| + // 24 hours are not allowed. |
| + explicit NightLightTime(int offset_minutes); |
| + NightLightTime(const NightLightTime& other); |
|
James Cook
2017/05/23 16:34:59
Does = default work here?
afakhry
2017/05/24 04:21:11
Yes. Done.
|
| + ~NightLightTime() = default; |
| + |
| + // Converts to a minutes offset representation from |time| dropping the |
| + // seconds and milliseconds. |
| + static NightLightTime FromTime(const base::Time& time); |
| + |
| + NightLightTime& operator=(const NightLightTime& rhs); |
|
James Cook
2017/05/23 16:34:59
Does = default work here?
nit: move up near Night
afakhry
2017/05/24 04:21:11
Done. I also added a test.
|
| + |
| + bool operator==(const NightLightTime& rhs) const; |
| + |
| + int offset_minutes_from_zero_hour() const { |
| + return offset_minutes_from_zero_hour_; |
| + } |
| + |
| + // Converts to an actual point in time today. |
| + base::Time ToTime() const; |
|
James Cook
2017/05/23 16:34:59
This might be clearer as ToTimeToday().
Also, doc
afakhry
2017/05/24 04:21:11
Done. Check my comment in the .cc file.
|
| + |
| + // Converts to a string in the format "3:07 PM". |
| + std::string ToString() const; |
| + |
| + private: |
| + int offset_minutes_from_zero_hour_; |
| +}; |
| + |
| +} // namespace ash |
| + |
| +#endif // ASH_SYSTEM_NIGHT_LIGHT_NIGHT_LIGHT_TIME_H_ |