【Foundation-72-2】NSTimeZone - 属性

本文详细介绍了NSTimeZone类的各种方法及属性,包括获取系统时区、设置默认时区、获取本地时区等,并展示了如何使用这些API来处理时区相关的编程问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >


@interface NSTimeZone (NSExtendedTimeZone)


+ (NSTimeZone *)systemTimeZone; 系统时区

+ (void)resetSystemTimeZone;


+ (NSTimeZone *)defaultTimeZone; 默认时区

+ (void)setDefaultTimeZone:(NSTimeZone *)aTimeZone;


+ (NSTimeZone *)localTimeZone; 本地时区


+ (NSArray *)knownTimeZoneNames;

    NSArray *arr = NSTimeZone.knownTimeZoneNames;
    
    for (NSUInteger a = 0; a < arr.count; a++) {
        NSLog(@"%@",[arr objectAtIndex:a]);
        
    }




+ (NSDictionary *)abbreviationDictionary;

+ (void)setAbbreviationDictionary:(NSDictionary *)dict NS_AVAILABLE(10_6, 4_0);

    NSDictionary *dic = NSTimeZone.abbreviationDictionary;
    NSLog(@"%@",dic);



+ (NSString *)timeZoneDataVersion NS_AVAILABLE(10_6, 4_0);

    NSString *string = NSTimeZone.timeZoneDataVersion;




@property (readonly) NSInteger secondsFromGMT; 时差

@property (readonly, copy) NSString *abbreviation; 简称

@property (readonly, getter=isDaylightSavingTime) BOOL daylightSavingTime; 夏时令

@property (readonly) NSTimeInterval daylightSavingTimeOffset NS_AVAILABLE(10_5, 2_0); // 

@property (readonly, copy) NSDate *nextDaylightSavingTimeTransition NS_AVAILABLE(10_5, 2_0); // 


@property (readonly, copy) NSString *description;


是否一致

- (BOOL)isEqualToTimeZone:(NSTimeZone *)aTimeZone;


typedef NS_ENUM(NSInteger, NSTimeZoneNameStyle) {

NSTimeZoneNameStyleStandard, // Central Standard Time

NSTimeZoneNameStyleShortStandard, // CST

NSTimeZoneNameStyleDaylightSaving, // Central Daylight Time

NSTimeZoneNameStyleShortDaylightSaving, // CDT

NSTimeZoneNameStyleGeneric, // Central Time

NSTimeZoneNameStyleShortGeneric // CT

};


- (NSString *)localizedName:(NSTimeZoneNameStyle)style locale:(NSLocale *)locale NS_AVAILABLE(10_5, 2_0);


@end



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值