NSDate(FWFoundation)

@interface NSDate (FWFoundation)

/// 转化为字符串,默认当前时区,格式:yyyy-MM-dd HH:mm:ss
@property (nonatomic, copy, readonly) NSString *fw_stringValue NS_REFINED_FOR_SWIFT;

/// 转化为字符串,默认当前时区,自定义格式
- (NSString *)fw_stringWithFormat:(NSString *)format NS_REFINED_FOR_SWIFT;

/// 转化为字符串,自定义格式和时区
- (NSString *)fw_stringWithFormat:(NSString *)format timeZone:(nullable NSTimeZone *)timeZone NS_REFINED_FOR_SWIFT;

/// 当前时间戳,没有设置过返回本地时间戳,可同步设置服务器时间戳,同步后调整手机时间不影响
@property (class, nonatomic, assign) NSTimeInterval fw_currentTime NS_REFINED_FOR_SWIFT;

/// 从字符串初始化日期,默认当前时区,格式:yyyy-MM-dd HH:mm:ss
+ (nullable NSDate *)fw_dateWithString:(NSString *)string NS_REFINED_FOR_SWIFT;

/// 从字符串初始化日期,默认当前时区,自定义格式
+ (nullable NSDate *)fw_dateWithString:(NSString *)string format:(NSString *)format NS_REFINED_FOR_SWIFT;

/// 从字符串初始化日期,自定义格式和时区
+ (nullable NSDate *)fw_dateWithString:(NSString *)string format:(NSString *)format timeZone:(nullable NSTimeZone *)timeZone NS_REFINED_FOR_SWIFT;

/// 格式化时长,格式"00:00"或"00:00:00"
+ (NSString *)fw_formatDuration:(NSTimeInterval)duration hasHour:(BOOL)hasHour NS_REFINED_FOR_SWIFT;

/// 格式化16位、13位时间戳为10位(秒)
+ (NSTimeInterval)fw_formatTimestamp:(NSTimeInterval)timestamp NS_REFINED_FOR_SWIFT;

@end

Undocumented

  • 转化为字符串,默认当前时区,格式:yyyy-MM-dd HH:mm:ss

    Declaration

    Objective-C

    @property (nonatomic, copy, readonly) NS_REFINED_FOR_SWIFT NSString *fw_stringValue;
  • 转化为字符串,默认当前时区,自定义格式

    Declaration

    Objective-C

    - (nonnull NSString *)fw_stringWithFormat:(nonnull NSString *)format;
  • 转化为字符串,自定义格式和时区

    Declaration

    Objective-C

    - (nonnull NSString *)fw_stringWithFormat:(nonnull NSString *)format
                                     timeZone:(nullable NSTimeZone *)timeZone;
  • 当前时间戳,没有设置过返回本地时间戳,可同步设置服务器时间戳,同步后调整手机时间不影响

    Declaration

    Objective-C

    @property (class, nonatomic) NSTimeInterval fw_currentTime;
  • 从字符串初始化日期,默认当前时区,格式:yyyy-MM-dd HH:mm:ss

    Declaration

    Objective-C

    + (nullable NSDate *)fw_dateWithString:(nonnull NSString *)string;
  • 从字符串初始化日期,默认当前时区,自定义格式

    Declaration

    Objective-C

    + (nullable NSDate *)fw_dateWithString:(nonnull NSString *)string
                                    format:(nonnull NSString *)format;
  • 从字符串初始化日期,自定义格式和时区

    Declaration

    Objective-C

    + (nullable NSDate *)fw_dateWithString:(nonnull NSString *)string
                                    format:(nonnull NSString *)format
                                  timeZone:(nullable NSTimeZone *)timeZone;
  • 格式化时长,格式"00:00"或"00:00:00"

    Declaration

    Objective-C

    + (nonnull NSString *)fw_formatDuration:(NSTimeInterval)duration
                                    hasHour:(BOOL)hasHour;
  • 格式化16位、13位时间戳为10位(秒)

    Declaration

    Objective-C

    + (NSTimeInterval)fw_formatTimestamp:(NSTimeInterval)timestamp;