static NSTimeInterval NSTimeIntervalFromTLSFileOutputStreamTimestamp()

in TwitterLoggingServiceTests/TLSLoggingTests.m [1099:1119]


static NSTimeInterval NSTimeIntervalFromTLSFileOutputStreamTimestamp(NSString *timestamp)
{
    NSMutableArray<NSString *> *timestampElements = [[timestamp componentsSeparatedByString:@":"] mutableCopy];
    if (!timestampElements) {
        timestampElements = [NSMutableArray array];
    }
    if ([timestampElements.lastObject rangeOfString:@"."].location != NSNotFound) {
        NSArray<NSString *> *dotSeperatedEnd = [timestampElements.lastObject componentsSeparatedByString:@"."];
        [timestampElements removeLastObject];
        [timestampElements addObjectsFromArray:dotSeperatedEnd];
    }
    while (timestampElements.count < 4) {
        [timestampElements insertObject:@"0" atIndex:0];
    }
    NSTimeInterval ti = 0;
    ti += [timestampElements[0] integerValue] * 60 * 60;
    ti += [timestampElements[1] integerValue] * 60;
    ti += [timestampElements[2] integerValue];
    ti += ((double)[timestampElements[3] integerValue]) / 1000.0f;
    return ti;
}