Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

newtoiphonesdk

macrumors 6502a
Original poster
Jul 30, 2010
567
2
I use an RSS Parser that is listing times wrong. Eastern Standard Time shows 1 hour later than what the actual time of the RSS Event is. So, I am trying to figure out how I can adjust this in code, so that in the cellForIndexAtPathRow method of TableView, it will show correct time. Here is the code I am using:
Code:
    NSDateFormatter * dateFormatter = [[[NSDateFormatter alloc] init] autorelease];
    [dateFormatter setTimeStyle:NSDateFormatterMediumStyle];
    [dateFormatter setDateStyle:NSDateFormatterMediumStyle];
    NSString *articleDateString = [dateFormatter stringFromDate:entry.articleDate];

The entry.articleDate comes from the RSS Parser earlier which returns:
Code:
    NSString *articleDateString = [item valueForChild:@"updated"];        
        NSDate *articleDate = [NSDate dateFromInternetDateTimeString:articleDateString formatHint:DateFormatHintRFC3339];

What do you think would be the best way to take the HH part of the string only, and subtract 1 off of it?
 
What do you think would be the best way to take the HH part of the string only, and subtract 1 off of it?

I would probably do something like:
Code:
NSDate *modifiedDate = [NSDate dateWithTimeInterval:-3600 sinceDate:articleDate];

The -3600 comes up with a date/time one hour earlier than the original one.

To get the hour portion only, I'd create another date formatter that only outputs hour (I think you'll have to make your own, totally custom one,) and then use stringFromDate on it.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.