@@ -80,9 +80,10 @@ CHIP_ERROR GetEpochTS(uint32_t & chipEpoch)
80
80
*
81
81
* @param unixEpoch (as time_t)
82
82
*
83
- * @return bitmap value for day of week as defined by EnergyEvse::TargetDayOfWeekBitmap
83
+ * @return bitmap value for day of week as defined by EnergyEvse::TargetDayOfWeekBitmap. Note
84
+ * only one bit will be set for the day of the week.
84
85
*/
85
- uint8_t GetLocalDayOfWeekFromUnixEpoch (time_t unixEpoch)
86
+ BitMask<EnergyEvse::TargetDayOfWeekBitmap> GetLocalDayOfWeekFromUnixEpoch (time_t unixEpoch)
86
87
{
87
88
// Define a timezone structure and initialize it to the local timezone
88
89
// This will capture any daylight saving time changes
@@ -101,9 +102,10 @@ uint8_t GetLocalDayOfWeekFromUnixEpoch(time_t unixEpoch)
101
102
/* *
102
103
* @brief Helper function to get current timestamp and work out the day of week based on localtime
103
104
*
104
- * @param reference to hold the day of week as a bitmap as defined by EnergyEvse::TargetDayOfWeekBitmap
105
+ * @return bitmap value for day of week as defined by EnergyEvse::TargetDayOfWeekBitmap. Note
106
+ * only one bit will be set for the current day.
105
107
*/
106
- CHIP_ERROR GetLocalDayOfWeekNow (uint8_t & dayOfWeekMap)
108
+ CHIP_ERROR GetLocalDayOfWeekNow (BitMask<EnergyEvse::TargetDayOfWeekBitmap> & dayOfWeekMap)
107
109
{
108
110
System::Clock::Milliseconds64 cTMs;
109
111
CHIP_ERROR err = chip::System::SystemClock ().GetClock_RealTimeMS (cTMs);
@@ -118,6 +120,33 @@ CHIP_ERROR GetLocalDayOfWeekNow(uint8_t & dayOfWeekMap)
118
120
return CHIP_NO_ERROR;
119
121
}
120
122
123
+ /* *
124
+ * @brief Helper function to get current timestamp and work out the current number of minutes
125
+ * past midnight based on localtime
126
+ *
127
+ * @param reference to hold the number of minutes past midnight
128
+ */
129
+ CHIP_ERROR GetMinutesPastMidnight (uint16_t & minutesPastMidnight)
130
+ {
131
+ chip::System::Clock::Milliseconds64 cTMs;
132
+ CHIP_ERROR err = chip::System::SystemClock ().GetClock_RealTimeMS (cTMs);
133
+ if (err != CHIP_NO_ERROR)
134
+ {
135
+ ChipLogError (Zcl, " EVSE: unable to get current time to check user schedules error=%" CHIP_ERROR_FORMAT, err.Format ());
136
+ return err;
137
+ }
138
+ time_t unixEpoch = std::chrono::duration_cast<chip::System::Clock::Seconds32>(cTMs).count ();
139
+
140
+ // Define a timezone structure and initialize it to the local timezone
141
+ // This will capture any daylight saving time changes
142
+ struct tm local_time;
143
+ localtime_r (&unixEpoch, &local_time);
144
+
145
+ minutesPastMidnight = static_cast <uint16_t >((local_time.tm_hour * 60 ) + local_time.tm_min );
146
+
147
+ return err;
148
+ }
149
+
121
150
} // namespace DeviceEnergyManagement
122
151
} // namespace Clusters
123
152
} // namespace app
0 commit comments