Skip to content

Commit

Permalink
Change to NSISO8601DateFormatter to ensure UTC timestamps in unit tes…
Browse files Browse the repository at this point in the history
…ts (#658)

Change to NSISO8601DateFormatter to ensure UTC timestamps in unit tests.
  • Loading branch information
pmarkowsky committed Oct 28, 2021
1 parent fe6be92 commit 7adc550
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions Source/santametricservice/Formats/SNTMetricFormatTestHelper.m
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,15 @@

@implementation SNTMetricFormatTestHelper
+ (NSDictionary *)convertDatesToFixedDateWithExportDict:(NSMutableDictionary *)exportDict {
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setDateFormat:@"yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"];
NSISO8601DateFormatter *formatter = [[NSISO8601DateFormatter alloc] init];

if (@available(macOS 10.13, *)) {
formatter.formatOptions =
NSISO8601DateFormatWithInternetDateTime | NSISO8601DateFormatWithFractionalSeconds;
} else {
[formatter setTimeZone:[NSTimeZone timeZoneWithName:@"UTC"]];
}

NSDate *fixedDate = [formatter dateFromString:@"2021-09-16T21:07:34.826Z"];

for (NSString *metricName in exportDict[@"metrics"]) {
Expand Down

0 comments on commit 7adc550

Please sign in to comment.