Skip to content

Commit

Permalink
updated CookMailPlugin with latest changes
Browse files Browse the repository at this point in the history
  • Loading branch information
ned committed Dec 20, 2019
1 parent 4d06e78 commit 017809b
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions CookMailPlugin/CookMailPlugin/ALTAnisetteData.m
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,10 @@ - (instancetype)initWithJSON:(NSDictionary<NSString *,NSString *> *)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
Expand Down Expand Up @@ -209,7 +212,9 @@ - (instancetype)initWithJSON:(NSDictionary<NSString *,NSString *> *)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;
Expand Down

0 comments on commit 017809b

Please sign in to comment.