//
// Created by yyqxiaoyin on 2019-04-18.
//

#import "NSString+MKRRadioManagerAdd.h"


@implementation NSString (MKRRadioManagerAdd)

+ (NSString *)HHmmssFormatStrig:(NSInteger)timeInterval {
    if (timeInterval == 0){
        return @"00:00:00";
    }
    int seconds = timeInterval % 60;
    int minutes = (timeInterval / 60) % 60;
    int hours = timeInterval / 3600;
    return [NSString stringWithFormat:@"%02d:%02d:%02d",hours,minutes,seconds];
}

+ (NSInteger)secondsFromHHmmssFormatStrig:(NSString *)timeString{
    if (!timeString.length) {
        return 0;
    }
    NSInteger seconds = 0;
    NSArray *arr = [timeString componentsSeparatedByString:@":"];
    NSArray *reverArr = [[arr reverseObjectEnumerator] allObjects];
    for (NSInteger i = 0; i<reverArr.count; i++) {
        NSInteger count = [reverArr[i] integerValue];
        NSInteger type = (int)pow(60, i);
        seconds += count * type;
    }
    
    return seconds;
}

@end
