Commits

Peter Hosey committed c644aad

Beefed up the calendar-date unparser test with a couple of command-line arguments.

Comments (0)

Files changed (1)

 	ISO8601DateFormatter *formatter = [[[ISO8601DateFormatter alloc] init] autorelease];
 	formatter.format = ISO8601DateFormatCalendar;
 
+	BOOL forceUTC = NO;
+
+	while (argv[1]) {
+		if (strcmp(argv[1], "--include-time") == 0)
+			formatter.includeTime = YES;
+		else if (strcmp(argv[1], "--force-utc") == 0)
+			forceUTC = YES;
+		else
+			break;
+		--argc;
+		++argv;
+	}
+
 	while(--argc) {
 		NSString *arg = [NSString stringWithUTF8String:*++argv];
 		NSTimeZone *timeZone = nil;
-		printf("%s\n", [[NSString stringWithFormat:@"%@:\t%@", arg, [formatter stringFromDate:[formatter dateFromString:arg timeZone:&timeZone] timeZone:timeZone]] UTF8String]);
+		NSDate *date = [formatter dateFromString:arg timeZone:&timeZone];
+		if (forceUTC)
+			timeZone = [NSTimeZone timeZoneWithAbbreviation:@"UTC"];
+		printf("%s\n", [[NSString stringWithFormat:@"%@:\t%@", arg, [formatter stringFromDate:date timeZone:timeZone]] UTF8String]);
 	}
 
 	[pool release];
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.