Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef ASH_SYSTEM_NIGHT_LIGHT_NIGHT_LIGHT_TIME_H_ | |
| 6 #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
| |
| 7 | |
| 8 #include <string> | |
| 9 | |
| 10 #include "ash/ash_export.h" | |
| 11 #include "base/time/time.h" | |
| 12 | |
| 13 namespace ash { | |
| 14 | |
| 15 // Represents the time of the day as a simple number of minutes since 00:00 | |
| 16 // regardless of the date or the timezone. This makes it simple to persist this | |
| 17 // as an integer user pref. | |
| 18 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.
| |
| 19 public: | |
| 20 // |offset_minutes| is the number of minutes since 00:00. If |offset_minutes| | |
| 21 // is equal to the offset minutes in 24 hours, it will be reset to 0 to | |
| 22 // represent the time 00:00 (12:00 AM). Offsets greater than the minutes in | |
| 23 // 24 hours are not allowed. | |
| 24 explicit NightLightTime(int offset_minutes); | |
| 25 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.
| |
| 26 ~NightLightTime() = default; | |
| 27 | |
| 28 // Converts to a minutes offset representation from |time| dropping the | |
| 29 // seconds and milliseconds. | |
| 30 static NightLightTime FromTime(const base::Time& time); | |
| 31 | |
| 32 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.
| |
| 33 | |
| 34 bool operator==(const NightLightTime& rhs) const; | |
| 35 | |
| 36 int offset_minutes_from_zero_hour() const { | |
| 37 return offset_minutes_from_zero_hour_; | |
| 38 } | |
| 39 | |
| 40 // Converts to an actual point in time today. | |
| 41 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.
| |
| 42 | |
| 43 // Converts to a string in the format "3:07 PM". | |
| 44 std::string ToString() const; | |
| 45 | |
| 46 private: | |
| 47 int offset_minutes_from_zero_hour_; | |
| 48 }; | |
| 49 | |
| 50 } // namespace ash | |
| 51 | |
| 52 #endif // ASH_SYSTEM_NIGHT_LIGHT_NIGHT_LIGHT_TIME_H_ | |
| OLD | NEW |