From 017809be765404a0b79d7526400ebbb90d6251fe Mon Sep 17 00:00:00 2001 From: ned Date: Fri, 20 Dec 2019 15:59:29 +0100 Subject: [PATCH] updated CookMailPlugin with latest changes --- CookMailPlugin/CookMailPlugin/ALTAnisetteData.m | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/CookMailPlugin/CookMailPlugin/ALTAnisetteData.m b/CookMailPlugin/CookMailPlugin/ALTAnisetteData.m index 50e8696..5680244 100644 --- a/CookMailPlugin/CookMailPlugin/ALTAnisetteData.m +++ b/CookMailPlugin/CookMailPlugin/ALTAnisetteData.m @@ -180,7 +180,10 @@ - (instancetype)initWithJSON:(NSDictionary *)json NSDate *date = [dateFormatter dateFromString:dateString]; NSLocale *locale = [NSLocale localeWithLocaleIdentifier:localeIdentifier]; - NSTimeZone *timeZone = [NSTimeZone timeZoneWithAbbreviation:timeZoneIdentifier]; + + // There is not a perfect mapping between NSTimeZone's and their identifiers, so it's possible timeZoneWithAbbreviation: will return nil. + // In this case, we'll default to the local time zone since that's most likely correct, and if not it shouldn't matter regardless. + NSTimeZone *timeZone = [NSTimeZone timeZoneWithAbbreviation:timeZoneIdentifier] ?: [NSTimeZone localTimeZone]; self = [self initWithMachineID:machineID oneTimePassword:oneTimePassword @@ -209,7 +212,9 @@ - (instancetype)initWithJSON:(NSDictionary *)json @"deviceDescription": self.deviceDescription, @"date": [dateFormatter stringFromDate:self.date], @"locale": self.locale.localeIdentifier, - @"timeZone": self.timeZone.abbreviation + + // NSTimeZone.abbreviation may be nil, so provide defaults. + @"timeZone": self.timeZone.abbreviation ?: NSTimeZone.localTimeZone.abbreviation ?: @"PST" }; return json;