NSDate(FWApplication)
@interface NSDate (FWApplication)
NSDate默认GMT时区;NSTimeZone默认系统时区(可设置应用默认时区);NSDateFormatter默认当前时区(可自定义),格式化时自动修正NSDate时区(无需手工修正NSDate);NSLocale默认当前语言环境
-
计算两个时间差,并格式化为友好的时间字符串(类似微博) <10分钟:刚刚 <60分钟:n分钟前 <24小时:n小时前 <7天:n天前 <365天:n月/n日 >=365天:n年/n月
Declaration
Objective-C
- (nonnull NSString *)fw_stringSinceDate:(nonnull NSDate *)date;
Return Value
字符串
-
转化为UTC时间戳
Declaration
Objective-C
@property (nonatomic, readonly) NSTimeInterval fw_timestampValue;
Return Value
UTC时间戳
-
Undocumented
Declaration
Objective-C
@property (nonatomic, strong, readonly) NSDate *fw_localTimeZoneDate
-
Undocumented
Declaration
Objective-C
@property (nonatomic, strong, readonly) NSDate *fw_utcTimeZoneDate
-
Undocumented
Declaration
Objective-C
- (NSDate *)fw_dateWithTimeZone:(nullable NSTimeZone *)timeZone NS_REFINED_FOR_SWIFT;
-
Undocumented
Declaration
Objective-C
- (NSInteger)fw_calendarUnit:(NSCalendarUnit)unit NS_REFINED_FOR_SWIFT;
-
Undocumented
Declaration
Objective-C
@property (nonatomic, readonly) BOOL fw_isLeapYear
-
Undocumented
Declaration
Objective-C
- (BOOL)fw_isSameDay:(NSDate *)date NS_REFINED_FOR_SWIFT;
-
Undocumented
Declaration
Objective-C
- (nullable NSDate *)fw_dateByAdding:(NSDateComponents *)components NS_REFINED_FOR_SWIFT;
-
Undocumented
Declaration
Objective-C
- (NSInteger)fw_daysFrom:(NSDate *)date NS_REFINED_FOR_SWIFT;
-
Undocumented
Declaration
Objective-C
- (NSTimeInterval)fw_secondsFrom:(NSDate *)date NS_REFINED_FOR_SWIFT;
-
系统运行时间
Declaration
Objective-C
@property (class, nonatomic, readonly) NSTimeInterval fw_systemUptime;
-
系统启动时间
Declaration
Objective-C
@property (class, nonatomic, readonly) NSTimeInterval fw_systemBoottime;
-
从时间戳初始化日期
Declaration
Objective-C
+ (nonnull NSDate *)fw_dateWithTimestamp:(NSTimeInterval)timestamp;
Parameters
timestamp
时间戳
Return Value
NSDate