Skip to content

Localize date based on user's region #20

Merged
merged 2 commits into from May 30, 2011
View
14 EGOTableViewPullRefresh/Classes/View/EGORefreshTableHeaderView.m
@@ -41,7 +41,7 @@ @implementation EGORefreshTableHeaderView
- (id)initWithFrame:(CGRect)frame arrowImageName:(NSString *)arrow textColor:(UIColor *)textColor {
- if (self = [super initWithFrame:frame]) {
+ if((self = [super initWithFrame:frame])) {
self.autoresizingMask = UIViewAutoresizingFlexibleWidth;
self.backgroundColor = [UIColor colorWithRed:226.0/255.0 green:231.0/255.0 blue:237.0/255.0 alpha:1.0];
@@ -112,14 +112,14 @@ - (void)refreshLastUpdatedDate {
NSDate *date = [_delegate egoRefreshTableHeaderDataSourceLastUpdated:self];
- NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
- [formatter setAMSymbol:@"AM"];
- [formatter setPMSymbol:@"PM"];
- [formatter setDateFormat:@"MM/dd/yyyy hh:mm:a"];
- _lastUpdatedLabel.text = [NSString stringWithFormat:@"Last Updated: %@", [formatter stringFromDate:date]];
+ [NSDateFormatter setDefaultFormatterBehavior:NSDateFormatterBehaviorDefault];
+ NSDateFormatter *dateFormatter = [[[NSDateFormatter alloc] init] autorelease];
+ [dateFormatter setDateStyle:NSDateFormatterShortStyle];
+ [dateFormatter setTimeStyle:NSDateFormatterShortStyle];
+
+ _lastUpdatedLabel.text = [NSString stringWithFormat:@"Last Updated: %@", [dateFormatter stringFromDate:date]];
[[NSUserDefaults standardUserDefaults] setObject:_lastUpdatedLabel.text forKey:@"EGORefreshTableView_LastRefresh"];
[[NSUserDefaults standardUserDefaults] synchronize];
- [formatter release];
} else {
Something went wrong with that request. Please try again.