Skip to content

Commit 870256f

Browse files
Fix date in days strucd and function CompareDay
1 parent 09d258e commit 870256f

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

examples/all-clusters-app/all-clusters-common/src/energy-calendar-instance.cpp

+17-1
Original file line numberDiff line numberDiff line change
@@ -238,11 +238,27 @@ void chip::app::Clusters::EnergyCalendar::CalendarProviderInstance::ErrorMessage
238238
DataModel::Nullable<Structs::DayStruct::Type> CalendarProviderInstance::GetDay(uint32_t date)
239239
{
240240
DataModel::Nullable<Structs::DayStruct::Type> result = std::nullopt;
241+
uint32_t dt;
242+
243+
uint16_t year;
244+
uint8_t month;
245+
uint8_t dayOfMonth;
246+
uint8_t hour;
247+
uint8_t minute;
248+
uint8_t second;
249+
ChipEpochToCalendarTime(date, year, month, dayOfMonth, hour, minute, second);
241250

242251
for (auto & day : mSpecialDays)
243252
{
244-
if (day.date.HasValue() && day.date.Value() == date)
253+
if (day.date.HasValue())
245254
{
255+
dt = day.date.Value();
256+
if (((dt & 0xFF)!=0xFF) && ((dt & 0xFF) != (uint8_t)(year - 1900)))
257+
continue;
258+
if (((dt >>8) & 0xFF) != month)
259+
continue;
260+
if (((dt >>16) & 0xFF) != dayOfMonth)
261+
continue;
246262
return day;
247263
}
248264
}

0 commit comments

Comments
 (0)