3

我有一个谓词返回选定日期的事件,但它返回具有不同时区的日期。如何使谓词根据本地时区搜索日期?

NSTimeInterval time = floor([[NSDate date] timeIntervalSinceReferenceDate] / 86400.0) * 86400.0;
NSDate *start = [NSDate dateWithTimeIntervalSinceReferenceDate:time];

NSTimeInterval secondsInTwentyFourHours = (24 * 60 * 60);
NSDate *end = [start dateByAddingTimeInterval:secondsInTwentyFourHours];

// Create the predicate from the event store's instance method
NSPredicate *predicate = [store predicateForEventsWithStartDate:start endDate:end calendars:nil];
// Fetch all events that match the predicate
events = [store eventsMatchingPredicate:predicate];
4

0 回答 0