Applying an offset to HMEventTrigger predicates has incorrect logic

Originator:angelad
Number:rdar://28825070 Date Originated:10/18/2016
Status:Closed Resolved:
Product:iOS Product Version:10.0
Classification: Reproducible:Yes
 
This bug is in regards to applying an offset to the following predicates of the HMEventTrigger class: 
  
- predicateForEvaluatingTriggerOccurringBeforeSignificantEvent
- predicateForEvaluatingTriggerOccurringAfterSignificantEvent

When creating a predicate that evaluates whether an event occurred before or after a significant event with an offset, (eg. 4 hours after sunrise), the 4 hours is currently being added to time now() rather than the time of the solar event. 

Example: Creating an HMEventTrigger in HomeKit 

HMCharacteristicEvent: Arbitrary HMCharacteristicEvent
NSPredicate: Sunrise (+ 4 hours)
HMActionSet: Arbitrary action set

If sunrise is at 7:00am and it's currently 10:00am, the predicate is evaluated as follows: 
7:00am <= now() + 4 hours
7:00am <= 2:00pm

This evaluates to true, and the HMEventTrigger fires, but it should not fire until 11:00am at the earliest (4 hours after sunrise). Adding the date components to the time of sunrise would resolve this issue.

7:00am + 4 hours <= now()
11:00am <= 10:00am

This expression evaluates to false and the HMEventTrigger will not fire, which is correct. 

This is the case for adding an offset to the following conditions: before sunrise, after sunrise, before sunset, and after sunset.

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!