iOS 判断当前是否是美股交易时间

+ (BOOL)currentInUSDealing {
    
    NSDate *today = [NSDate date];
    NSTimeZone *est = [NSTimeZone timeZoneForSecondsFromGMT:-5 * 3600];
    
    NSCalendar *claendar = [NSCalendar currentCalendar];
    claendar.timeZone = est;
    if ([claendar isDateInWeekend:today]) {
        return NO;
    }
    
    NSDateFormatter *formater = [[NSDateFormatter alloc] init];
    [formater setDateFormat:@"HH:mm:ss"];
    [formater setTimeZone:est];
    NSString *todayStr = [formater stringFromDate:today];
    NSString *startTimeStr = @"09:30:00";
    NSString *endTimeStr = @"16:00:00";
    return ([todayStr compare:startTimeStr] != kCFCompareLessThan) && ([todayStr compare:endTimeStr] != kCFCompareGreaterThan);
}

你可能感兴趣的:(iOS 判断当前是否是美股交易时间)