From b90828014bdaa359c1b5684ec3b0ff6e411a0cf6 Mon Sep 17 00:00:00 2001 From: mikyl Date: Thu, 28 May 2015 15:13:01 +0200 Subject: [PATCH] resolve DLNAService parsing of date with fraction of seconds (ex 00:03:41.256) --- Services/DLNAService.m | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/Services/DLNAService.m b/Services/DLNAService.m index 5d955a29..b2ac56a4 100644 --- a/Services/DLNAService.m +++ b/Services/DLNAService.m @@ -746,16 +746,14 @@ - (NSTimeInterval) timeForString:(NSString *)timeString if (!timeString || [timeString isEqualToString:@""]) return 0; - NSDateFormatter *formatter = [[NSDateFormatter alloc] init]; - [formatter setDateFormat:@"HH:m:ss"]; - - NSDate *time = [formatter dateFromString:timeString]; - NSDate *midnight = [formatter dateFromString:@"00:00:00"]; - - NSTimeInterval timeInterval = [time timeIntervalSinceDate:midnight]; - - if (timeInterval < 0) - timeInterval = 0; + NSTimeInterval timeInterval = 0; + NSArray* timeArray = [timeString componentsSeparatedByString:@":"]; + if(timeArray.count == 3) { + NSUInteger hour = ((NSString*)timeArray[0]).longLongValue; + NSUInteger minutes = ((NSString*)timeArray[1]).longLongValue; + NSUInteger seconds = ((NSString*)timeArray[2]).longLongValue; + timeInterval = hours*3600 + minutes*60 + seconds; + } return timeInterval; }