My app uses a feed from localendar.com to create a tableview of upcoming events. The issue though, is that the feeds from localendar do not account for DST, so they end up showing the pubDate of the feed as 1 hour later than the event actually starts. My app parses the feed and takes the date into the detail line in the cell, which makes it confusing. I am trying to get my app to detect whether or not the user is in DST, and if they are, subtract one hour from the date. However, when I use the code below, nothing changes, and a NSLog never gets called on the isDaylightSavingsTime property tag.
UPDATE:
I have tried a different approach in changing it up in the cellForRowAtIndexPath:
NSDateFormatter * dateFormatter = [[[NSDateFormatter alloc] init] autorelease];
[dateFormatter setTimeZone:[NSTimeZone localTimeZone]];
[dateFormatter setTimeStyle:NSDateFormatterShortStyle];
[dateFormatter setDateStyle:NSDateFormatterShortStyle];
NSString *articleDateString = [dateFormatter stringFromDate:entry.articleDate];
NSLog(@"after formatter %@", articleDateString);
cell.detailTextLabel.text = [NSString stringWithFormat:@"%@", articleDateString];
The issue is that the time in the RSS feed pubDate does not adjust for DST, so it is an hour off half of the year. The formatter does everything correct by time zone, because the time in the feed is already wrong as it uses GMT and not US Time.
PLEASE, do NOT vote to close this. This is not too localized, it applies to every state in the USA that has daylight savings time.
Here are two pics to describe the issue better. The first shows what is in the RSS Feed, and the second shows what is in the calendar which is the correct time.
As you see, that time in the feed shows as 10:00, while the actual time that displays every place BUT the RSS feed shows as:
Update 2:
I tried setting the timezone to Central manually in my code, but it still does the same thing. In cellForRowAtIndexPath I have:
RSSEntry *entry = [_allEntries objectAtIndex:indexPath.row];
NSDateFormatter * dateFormatter = [[[NSDateFormatter alloc] init] autorelease];
[dateFormatter setTimeZone:[NSTimeZone timeZoneWithName:@"America/Menominee"]];
[dateFormatter setTimeStyle:NSDateFormatterShortStyle];
[dateFormatter setDateStyle:NSDateFormatterShortStyle];
cell.detailTextLabel.text = [NSString stringWithFormat:@"%@", articleDateString];
However, instead of getting the detailTextLabel.text to show 5/27/13 10:00 PM, it shows 5/27/13 11:00 PM still.