-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
validate address should allow addresslabel in place of street + number, fix timezone json conversion issues. #371
Changes from all commits
0064420
603df96
d06b035
7ec22e7
700d734
cfb57f1
edf96ff
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,16 @@ | |
#import "RadarTimeZone.h" | ||
#import "RadarUtils.h" | ||
|
||
NSDateFormatter *_timezoneDateFormatter = nil; | ||
NSDateFormatter * timezoneDateFormatter(void) { | ||
if (_timezoneDateFormatter == nil) { | ||
_timezoneDateFormatter = [[NSDateFormatter alloc] init]; | ||
_timezoneDateFormatter.locale = [[NSLocale alloc] initWithLocaleIdentifier:@"en_US_POSIX"]; | ||
[_timezoneDateFormatter setDateFormat:@"yyyy-MM-dd'T'HH:mm:ssZZZZZ"]; | ||
} | ||
return _timezoneDateFormatter; | ||
} | ||
|
||
@implementation RadarTimeZone | ||
|
||
- (instancetype _Nullable)initWithObject:(id)object { | ||
|
@@ -35,7 +45,8 @@ - (instancetype _Nullable)initWithObject:(id)object { | |
|
||
id currentTimeObj = dict[@"currentTime"]; | ||
if (currentTimeObj && [currentTimeObj isKindOfClass:[NSString class]]) { | ||
_currentTime = [RadarUtils.isoDateFormatter dateFromString:(NSString *)currentTimeObj]; | ||
|
||
_currentTime = [timezoneDateFormatter() dateFromString:(NSString *)currentTimeObj]; | ||
} | ||
|
||
id utcOffsetObj = dict[@"utcOffset"]; | ||
|
@@ -56,7 +67,7 @@ - (NSDictionary *)dictionaryValue { | |
dict[@"_id"] = self._id; | ||
dict[@"name"] = self.name; | ||
dict[@"code"] = self.code; | ||
dict[@"currentTime"] = self.currentTime; | ||
dict[@"currentTime"] = [timezoneDateFormatter() stringFromDate:self.currentTime]; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the current time string from server is a different format (no millisecond) so we need a different parser than RadarUtils.isoDateFormatter |
||
dict[@"utcOffset"] = @(self.utcOffset); | ||
dict[@"dstOffset"] = @(self.dstOffset); | ||
return dict; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -89,7 +89,7 @@ - (NSDictionary *)dictionaryValue { | |
dict[kDestinationGeofenceTag] = self.destinationGeofenceTag; | ||
dict[kDestinationGeofenceExternalId] = self.destinationGeofenceExternalId; | ||
dict[kMode] = [Radar stringForMode:self.mode]; | ||
dict[kScheduledArrivalAt] = self.scheduledArrivalAt; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. NSDate object does not get converted, this field was null, format it to string since all our other date formats are converted to string with JSON |
||
dict[kScheduledArrivalAt] = [RadarUtils.isoDateFormatter stringFromDate:self.scheduledArrivalAt]; | ||
if (self.approachingThreshold && self.approachingThreshold > 0) { | ||
dict[kApproachingThreshold] = @(self.approachingThreshold); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably there no action items for with respect to this PR, but we really should consider having a more "central" place where we define our time parsers. There are quite a few definitions littered around the codebase. Just a call out to keep in mind for the future.