增加换肤功能
This commit is contained in:
68
Pods/AliyunOSSiOS/AliyunOSSSDK/NSDate+OSS.m
generated
Normal file
68
Pods/AliyunOSSiOS/AliyunOSSSDK/NSDate+OSS.m
generated
Normal file
@@ -0,0 +1,68 @@
|
||||
//
|
||||
// NSDate+OSS.m
|
||||
// AliyunOSSSDK
|
||||
//
|
||||
// Created by huaixu on 2018/7/31.
|
||||
// Copyright © 2018年 aliyun. All rights reserved.
|
||||
//
|
||||
|
||||
#import "NSDate+OSS.h"
|
||||
|
||||
@implementation NSDate (OSS)
|
||||
|
||||
NSString * const serverReturnDateFormat = @"EEE, dd MMM yyyy HH:mm:ss z";
|
||||
|
||||
static NSTimeInterval _clockSkew = 0.0;
|
||||
|
||||
+ (void)oss_setClockSkew:(NSTimeInterval)clockSkew {
|
||||
@synchronized(self) {
|
||||
_clockSkew = clockSkew;
|
||||
}
|
||||
}
|
||||
|
||||
+ (NSDate *)oss_clockSkewFixedDate {
|
||||
NSTimeInterval skew = 0.0;
|
||||
@synchronized(self) {
|
||||
skew = _clockSkew;
|
||||
}
|
||||
return [[NSDate date] dateByAddingTimeInterval:(-1 * skew)];
|
||||
}
|
||||
|
||||
+ (NSDate *)oss_dateFromString:(NSString *)string {
|
||||
NSDateFormatter *dateFormatter = [NSDateFormatter new];
|
||||
dateFormatter.timeZone = [NSTimeZone timeZoneWithName:@"GMT"];
|
||||
dateFormatter.locale = [NSLocale localeWithLocaleIdentifier:@"en_US"];
|
||||
dateFormatter.dateFormat = serverReturnDateFormat;
|
||||
|
||||
return [dateFormatter dateFromString:string];
|
||||
}
|
||||
|
||||
- (NSString *)oss_asStringValue {
|
||||
NSDateFormatter *dateFormatter = [NSDateFormatter new];
|
||||
dateFormatter.timeZone = [NSTimeZone timeZoneWithName:@"GMT"];
|
||||
dateFormatter.locale = [NSLocale localeWithLocaleIdentifier:@"en_US"];
|
||||
dateFormatter.dateFormat = serverReturnDateFormat;
|
||||
|
||||
return [dateFormatter stringFromDate:self];
|
||||
}
|
||||
|
||||
+ (NSDate *)oss_dateFromString:(NSString *)string
|
||||
dateFormat:(NSString *)dateFormat {
|
||||
NSDateFormatter *dateFormatter = [NSDateFormatter new];
|
||||
dateFormatter.timeZone = [NSTimeZone timeZoneWithName:@"GMT"];
|
||||
dateFormatter.locale = [NSLocale localeWithLocaleIdentifier:@"en_US"];
|
||||
dateFormatter.dateFormat = dateFormat;
|
||||
|
||||
return [dateFormatter dateFromString:string];
|
||||
}
|
||||
|
||||
- (NSString *)oss_asStringValueWithDateFormat:(NSString *)dateFormat {
|
||||
NSDateFormatter *dateFormatter = [NSDateFormatter new];
|
||||
dateFormatter.timeZone = [NSTimeZone timeZoneWithName:@"GMT"];
|
||||
dateFormatter.locale = [NSLocale localeWithLocaleIdentifier:@"en_US"];
|
||||
dateFormatter.dateFormat = dateFormat;
|
||||
|
||||
return [dateFormatter stringFromDate:self];
|
||||
}
|
||||
|
||||
@end
|
||||
Reference in New Issue
Block a user