mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-04-29 12:46:58 +02:00
EventFormatter: Fix local time zone handling
This commit is contained in:
@@ -22,6 +22,11 @@
|
||||
The calendar used to retrieve the today date.
|
||||
*/
|
||||
NSCalendar *calendar;
|
||||
|
||||
/**
|
||||
The local time zone
|
||||
*/
|
||||
NSTimeZone *localTimeZone;
|
||||
}
|
||||
@end
|
||||
|
||||
@@ -35,6 +40,8 @@
|
||||
calendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSCalendarIdentifierGregorian];
|
||||
// Note: NSDate object always shows time according to GMT, so the calendar should be in GMT too.
|
||||
calendar.timeZone = [NSTimeZone timeZoneWithAbbreviation:@"GMT"];
|
||||
|
||||
localTimeZone = [NSTimeZone localTimeZone];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
@@ -56,7 +63,9 @@
|
||||
NSDateComponents *components = [calendar components:(NSCalendarUnitYear | NSCalendarUnitMonth | NSCalendarUnitDay) fromDate:[NSDate date]];
|
||||
NSDate *today = [calendar dateFromComponents:components];
|
||||
|
||||
NSTimeInterval interval = -[date timeIntervalSinceDate:today];
|
||||
NSTimeInterval localZoneOffset = [localTimeZone secondsFromGMT];
|
||||
|
||||
NSTimeInterval interval = -[date timeIntervalSinceDate:today] - localZoneOffset;
|
||||
if (interval > 60*60*24*6)
|
||||
{
|
||||
dateFormat = @"EEE MMM dd yyyy";
|
||||
|
||||
Reference in New Issue
Block a user