Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(69)

Side by Side Diff: ash/system/night_light/time_of_day.h

Issue 2887913004: [Night Light] CL4: Automatic schedule backend. (Closed)
Patch Set: James' comments Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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_TIME_OF_DAY_H_
6 #define ASH_SYSTEM_NIGHT_LIGHT_TIME_OF_DAY_H_
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 TimeOfDay {
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 TimeOfDay(int offset_minutes);
25 TimeOfDay(const TimeOfDay& other) = default;
26 TimeOfDay& operator=(const TimeOfDay& rhs) = default;
27 ~TimeOfDay() = default;
28
29 // Converts to a minutes offset representation from |time| dropping the
30 // seconds and milliseconds.
31 static TimeOfDay FromTime(const base::Time& time);
32
33 bool operator==(const TimeOfDay& rhs) const;
34
35 int offset_minutes_from_zero_hour() const {
36 return offset_minutes_from_zero_hour_;
37 }
38
39 // Converts to an actual point in time today. If this fail for some reason,
40 // 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.
41 base::Time ToTimeToday() const;
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_TIME_OF_DAY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698