From 00e14b746bcfb31f472fe5baf5564e1ef4457481 Mon Sep 17 00:00:00 2001 From: bitm0de Date: Sat, 15 Feb 2020 14:32:46 -0700 Subject: [PATCH] Added floating point epsilon comparison for equality check --- .../Essentials Devices Common/Codec/iHasScheduleAwareness.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/Codec/iHasScheduleAwareness.cs b/essentials-framework/Essentials Devices Common/Essentials Devices Common/Codec/iHasScheduleAwareness.cs index 5a006388..57839471 100644 --- a/essentials-framework/Essentials Devices Common/Essentials Devices Common/Codec/iHasScheduleAwareness.cs +++ b/essentials-framework/Essentials Devices Common/Essentials Devices Common/Codec/iHasScheduleAwareness.cs @@ -73,17 +73,18 @@ namespace PepperDash.Essentials.Devices.Common.Codec { // Iterate the meeting list and check if any meeting need to do anythingk + const double meetingTimeEpsilon = 0.0001; foreach (Meeting m in Meetings) { eMeetingEventChangeType changeType = eMeetingEventChangeType.Unkown; if (m.TimeToMeetingStart.TotalMinutes <= m.MeetingWarningMinutes.TotalMinutes) // Meeting is about to start changeType = eMeetingEventChangeType.MeetingStartWarning; - else if (m.TimeToMeetingStart.TotalMinutes == 0) // Meeting Start + else if (Math.Abs(m.TimeToMeetingStart.TotalMinutes) < meetingTimeEpsilon) // Meeting Start changeType = eMeetingEventChangeType.MeetingStart; else if (m.TimeToMeetingEnd.TotalMinutes <= m.MeetingWarningMinutes.TotalMinutes) // Meeting is about to end changeType = eMeetingEventChangeType.MeetingEndWarning; - else if (m.TimeToMeetingEnd.TotalMinutes == 0) // Meeting has ended + else if (Math.Abs(m.TimeToMeetingEnd.TotalMinutes) < meetingTimeEpsilon) // Meeting has ended changeType = eMeetingEventChangeType.MeetingEnd; if (changeType != eMeetingEventChangeType.Unkown)