Skip to content

Commit

Permalink
Remove RRFC3339DateTool
Browse files Browse the repository at this point in the history
  • Loading branch information
kstenerud committed Nov 24, 2016
1 parent fd9087a commit 15d81ea
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 233 deletions.
24 changes: 0 additions & 24 deletions Mac/KSCrash-Mac.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,18 @@


#import <XCTest/XCTest.h>
#import "RFC3339DateTool.h"
#import "RFC3339UTFString.h"


@interface RFC3339DateTool_Tests : XCTestCase @end

NSString* stringFromDate(NSDate* date)
{
char string[21];
time_t timestamp = (time_t)date.timeIntervalSince1970;
rfc3339UtcStringFromUNIXTimestamp(timestamp, string);
return [NSString stringWithUTF8String:string];
}

@implementation RFC3339DateTool_Tests

Expand All @@ -55,34 +62,10 @@ - (void) testStringFromDate
{
NSDate* date = [self gmtDateWithYear:2000 month:1 day:2 hour:3 minute:4 second:5];
NSString* expected = @"2000-01-02T03:04:05Z";
NSString* actual = [RFC3339DateTool stringFromDate:date];
NSString* actual = stringFromDate(date);

XCTAssertEqualObjects(actual, expected, @"");
}

- (void) testDateFromString
{
NSDate* expected = [self gmtDateWithYear:2000 month:1 day:2 hour:3 minute:4 second:5];
NSDate* actual = [RFC3339DateTool dateFromString:@"2000-01-02T03:04:05Z"];

XCTAssertEqualObjects(actual, expected, @"");
}

- (void) testStringFromUnixTimestamp
{
NSDate* date = [self gmtDateWithYear:2000 month:1 day:2 hour:3 minute:4 second:5];
NSString* expected = @"2000-01-02T03:04:05Z";
NSString* actual = [RFC3339DateTool stringFromUNIXTimestamp:(uint64_t)[date timeIntervalSince1970]];

XCTAssertEqualObjects(actual, expected, @"");
}
#if 0
- (void) testUnixTimestampFromString
{
uint64_t expected = (uint64_t)[[self gmtDateWithYear:2000 month:1 day:2 hour:3 minute:4 second:5] timeIntervalSince1970];
uint64_t actual = [RFC3339DateTool UNIXTimestampFromString:@"2000-01-02T03:04:05Z"];

XCTAssertEqual(actual, expected, @"");
}
#endif
@end

8 changes: 5 additions & 3 deletions Source/KSCrash/Recording/Tools/KSJSONCodecObjC.m
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

#import "KSJSONCodec.h"
#import "NSError+SimpleConstructor.h"
#import "RFC3339DateTool.h"
#import "RFC3339UTFString.h"


@interface KSJSONCodec ()
Expand Down Expand Up @@ -500,8 +500,10 @@ int ksjsoncodecobjc_i_encodeObject(KSJSONCodec* codec,

if([object isKindOfClass:[NSDate class]])
{
NSData* data = [[RFC3339DateTool stringFromDate:object]
dataUsingEncoding:NSUTF8StringEncoding];
char string[21];
time_t timestamp = (time_t)((NSDate*)object).timeIntervalSince1970;
rfc3339UtcStringFromUNIXTimestamp(timestamp, string);
NSData* data = [NSData dataWithBytes:string length:strnlen(string, 20)];
return ksjson_addStringElement(context, cName, data.bytes, (int)data.length);
}

Expand Down
11 changes: 9 additions & 2 deletions Source/KSCrash/Reporting/Filters/KSCrashReportFilterAppleFmt.m
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
#import "KSCrashReportFields.h"
#import "KSJSONCodecObjC.h"
#import "KSSystemInfo.h"
#import "RFC3339DateTool.h"


#if defined(__LP64__)
Expand Down Expand Up @@ -106,6 +105,9 @@ @implementation KSCrashReportFilterAppleFmt
/** Date formatter for Apple date format in crash reports. */
NSDateFormatter* g_dateFormatter;

/** Date formatter for RFC3339 date format. */
NSDateFormatter* g_rfc3339DateFormatter;

/** Printing order for registers. */
NSDictionary* g_registerOrders;

Expand All @@ -115,6 +117,11 @@ + (void) initialize
[g_dateFormatter setLocale:[NSLocale localeWithLocaleIdentifier:@"en_US_POSIX"]];
[g_dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss.SSS ZZZ"];

g_rfc3339DateFormatter = [[NSDateFormatter alloc] init];
[g_rfc3339DateFormatter setLocale:[NSLocale localeWithLocaleIdentifier:@"en_US_POSIX"]];
[g_rfc3339DateFormatter setDateFormat:@"yyyy'-'MM'-'dd'T'HH':'mm':'ss'Z'"];
[g_rfc3339DateFormatter setTimeZone:[NSTimeZone timeZoneForSecondsFromGMT:0]];

NSArray* armOrder = [NSArray arrayWithObjects:
@"r0", @"r1", @"r2", @"r3", @"r4", @"r5", @"r6", @"r7",
@"r8", @"r9", @"r10", @"r11", @"ip",
Expand Down Expand Up @@ -411,7 +418,7 @@ - (NSString*) headerStringForReport:(NSDictionary*) report
NSDictionary* system = [self systemReport:report];
NSDictionary* reportInfo = [self infoReport:report];
NSString *reportID = [reportInfo objectForKey:@KSCrashField_ID];
NSDate* crashTime = [RFC3339DateTool dateFromString:[reportInfo objectForKey:@KSCrashField_Timestamp]];
NSDate* crashTime = [g_rfc3339DateFormatter dateFromString:[reportInfo objectForKey:@KSCrashField_Timestamp]];

return [self headerStringForSystemInfo:system reportID:reportID crashTime:crashTime];
}
Expand Down
58 changes: 0 additions & 58 deletions Source/KSCrash/Reporting/Tools/RFC3339DateTool.h

This file was deleted.

71 changes: 0 additions & 71 deletions Source/KSCrash/Reporting/Tools/RFC3339DateTool.m

This file was deleted.

Loading

0 comments on commit 15d81ea

Please sign in to comment.