Chromium Code Reviews| Index: ash/system/night_light/time_of_day.h |
| diff --git a/ash/system/night_light/time_of_day.h b/ash/system/night_light/time_of_day.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..b270b8f5b9e05c98f48f5791ae81712eb6590d7c |
| --- /dev/null |
| +++ b/ash/system/night_light/time_of_day.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_TIME_OF_DAY_H_ |
| +#define ASH_SYSTEM_NIGHT_LIGHT_TIME_OF_DAY_H_ |
| + |
| +#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 TimeOfDay { |
| + 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 TimeOfDay(int offset_minutes); |
| + TimeOfDay(const TimeOfDay& other) = default; |
| + TimeOfDay& operator=(const TimeOfDay& rhs) = default; |
| + ~TimeOfDay() = default; |
| + |
| + // Converts to a minutes offset representation from |time| dropping the |
| + // seconds and milliseconds. |
| + static TimeOfDay FromTime(const base::Time& time); |
| + |
| + bool operator==(const TimeOfDay& rhs) const; |
| + |
| + int offset_minutes_from_zero_hour() const { |
| + return offset_minutes_from_zero_hour_; |
| + } |
| + |
| + // Converts to an actual point in time today. If this fail for some reason, |
| + // the NULL time will be returned. |
|
James Cook
2017/05/24 15:42:47
nit: "NULL time" seems weird. Maybe Time() or "epo
afakhry
2017/05/24 16:25:35
Done.
|
| + base::Time ToTimeToday() const; |
| + |
| + // 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_TIME_OF_DAY_H_ |