forked from boredzo/iso-8601-date-formatter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
testparser.m
27 lines (21 loc) · 796 Bytes
/
testparser.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#import <Foundation/Foundation.h>
#import "ISO8601DateFormatter.h"
int main(int argc, const char **argv) {
NSAutoreleasePool *pool = [NSAutoreleasePool new];
BOOL parseStrictly = NO;
if((argc > 1) && (strcmp(argv[1], "--strict") == 0)) {
--argc;++argv;
parseStrictly = YES;
}
[NSTimeZone setDefaultTimeZone:[NSTimeZone timeZoneForSecondsFromGMT:+0]];
ISO8601DateFormatter *formatter = [[[ISO8601DateFormatter alloc] init] autorelease];
formatter.parsesStrictly = parseStrictly;
while(--argc) {
NSString *str = [NSString stringWithUTF8String:*++argv];
NSLog(@"Parsing strictly: %hhi", parseStrictly);
NSDate *date = [formatter dateFromString:str];
fputs([[NSString stringWithFormat:@"%@ %C %@\n", str, 0x2192, date] UTF8String], stdout);
}
[pool release];
return 0;
}