Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

resolve DLNAService parsing of date with fraction of seconds #26

Open
wants to merge 4 commits into
base: dev
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 8 additions & 10 deletions Services/DLNAService.m
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down