-
Notifications
You must be signed in to change notification settings - Fork 1
/
gitDateToHumanReadableTransformer.m
51 lines (33 loc) · 1.14 KB
/
gitDateToHumanReadableTransformer.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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
//
// gitDateToHumanReadableTransformer.m
// SkeinFox
//
// Created by Jordan on 10/20/09.
// Copyright 2009 __MyCompanyName__. All rights reserved.
//
#import "gitDateToHumanReadableTransformer.h"
@implementation gitDateToHumanReadableTransformer
+ (Class)transformedValueClass
{
return [NSString class];
}
+ (BOOL)allowsReverseTransformation
{
return NO;
}
- (id)transformedValue:(id)value
{
if (value == nil) return nil;
// assume default behavior set for class using
// [NSDateFormatter setDefaultFormatterBehavior:NSDateFormatterBehavior10_4];
NSDateFormatter *dateFormatter =
[[[NSDateFormatter alloc] init] autorelease];
[dateFormatter setDateStyle:NSDateFormatterMediumStyle];
[dateFormatter setTimeStyle:NSDateFormatterMediumStyle];
NSDate *date = [NSDate dateWithString:value];
NSString *formattedDateString = [dateFormatter stringFromDate:date];
//NSLog(@"formattedDateString for locale %@: %@", [[dateFormatter locale] localeIdentifier], formattedDateString);
// Output: formattedDateString for locale en_US: Jan 2, 2001
return formattedDateString;
}
@end