views:

24

answers:

0

I use this method to turn a time interval into a string of the form MM:SS

NSTimeInterval testTime = 60.0; // for example  

NSCalendar *sysCalendar = [NSCalendar currentCalendar];  
NSUInteger minuteAndSecondComponents = (NSMinuteCalendarUnit | NSSecondCalendarUnit);  
NSDate *intervalDate = [NSDate dateWithTimeIntervalSinceNow:testTime];  
NSDateComponents *timeInfo = [sysCalendar components:minuteAndSecondComponents fromDate:[NSDate date] toDate:intervalDate options:0];  
NSString *timeString = [NSString stringWithFormat:@"%02d:%02d", [timeInfo minute], [timeInfo second]];  

NSLog(@"Time interval %g as string '%@'", testTime, timeString);  

The result on a device running iOS4 is: Time interval 60 as string '00:59'

But on a device running iPhoneOS 3.1.3 I get: Time interval 60 as string '01:00'

What could be causing this difference?

I checked the documentation for NSCalendar and NSDateComponents and didn't see any change. I also checked the Document Revision History for the Date and Time Programming Guide and didn't see any mention of changed behavior.