Permalink
Browse files

Neeeded to add a locale to the date parser.

  • Loading branch information...
1 parent e0bcf8e commit 48b070b26b586b8581bd2beca09eb3c918a0f16e @ryangrimm ryangrimm committed Apr 25, 2012
Showing with 9 additions and 11 deletions.
  1. +9 −11 Models/MLWSession.m
View
20 Models/MLWSession.m
@@ -82,30 +82,28 @@ - (NSString *)dayOfWeek {
}
- (NSString *)formattedDate {
- NSDateFormatter *startFormat = [[[NSDateFormatter alloc] init] autorelease];
- startFormat.timeZone = [NSTimeZone timeZoneWithAbbreviation:@"EDT"];
- [startFormat setDateFormat:@"EEEE, h:mma"];
-
- NSDateFormatter *endFormat = [[[NSDateFormatter alloc] init] autorelease];
- endFormat.timeZone = [NSTimeZone timeZoneWithAbbreviation:@"EDT"];
- [endFormat setDateStyle:NSDateFormatterNoStyle];
- [endFormat setTimeStyle:NSDateFormatterShortStyle];
+ NSDateFormatter *format = [[[NSDateFormatter alloc] init] autorelease];
+ format.timeZone = [NSTimeZone timeZoneWithAbbreviation:@"EDT"];
+ [format setDateStyle:NSDateFormatterNoStyle];
+ [format setTimeStyle:NSDateFormatterShortStyle];
- return [NSString stringWithFormat:@"%@ - %@", [startFormat stringFromDate:_startTime], [endFormat stringFromDate:_endTime]];
+ return [NSString stringWithFormat:@"%@, %@ - %@", self.dayOfWeek, [format stringFromDate:_startTime], [format stringFromDate:_endTime]];
}
- (NSString *)formattedTime {
NSDateFormatter *format = [[[NSDateFormatter alloc] init] autorelease];
format.timeZone = [NSTimeZone timeZoneWithAbbreviation:@"EDT"];
- [format setDateFormat:@"h:mma"];
+ [format setDateStyle:NSDateFormatterNoStyle];
+ [format setTimeStyle:NSDateFormatterShortStyle];
return [[NSString stringWithFormat:@"%@ - %@", [format stringFromDate:_startTime], [format stringFromDate:_endTime]] lowercaseString];
}
- (NSDate *)stringToDate:(NSString *) dateString {
NSDateFormatter *dateFormat = [[[NSDateFormatter alloc] init] autorelease];
- dateFormat.timeZone = [NSTimeZone timeZoneWithAbbreviation:@"EDT"];
+ dateFormat.locale = [[[NSLocale alloc] initWithLocaleIdentifier:@"en_US"] autorelease];
+ // 2012-05-01T07:30:00-0400
[dateFormat setDateFormat:@"yyyy-MM-dd'T'HH:mm:ssZZZ"];
NSRange timezone = NSMakeRange([dateString length] - 3, 3);
NSString *cleanDate = [dateString stringByReplacingOccurrencesOfString:@":" withString:@"" options:NSCaseInsensitiveSearch range:timezone];

0 comments on commit 48b070b

Please sign in to comment.