-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnsdate.m
23 lines (22 loc) · 817 Bytes
/
nsdate.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#import <Foundation/Foundation.h>
int main (int argc, const char * argv[])
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
NSString *dateFormat = @"";
dateFormatter.dateStyle = NSDateFormatterMediumStyle;
dateFormatter.timeStyle = NSDateFormatterMediumStyle;
for (int i = 1; i < argc; i++) {
if ([dateFormat length] != 0) {
dateFormat = [dateFormat stringByAppendingString:@" "];
}
dateFormat = [dateFormat stringByAppendingString:@(argv[i])];
}
if ([dateFormat length] != 0) {
dateFormatter.dateFormat = dateFormat;
}
NSDate *date = [NSDate date];
printf("%s\n", [[dateFormatter stringFromDate:date] UTF8String]);
[pool drain];
return 0;
}