Advertisement
hosamkora

NSTimeZone.h

Jul 8th, 2024 (edited)
511
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*  NSTimeZone.h
  2.     Copyright (c) 1994-2019, Apple Inc. All rights reserved.
  3. */
  4.  
  5. #import <Foundation/NSObject.h>
  6. #import <Foundation/NSDate.h>
  7. #import <Foundation/NSNotification.h>
  8.  
  9. @class NSString, NSArray<ObjectType>, NSDictionary<KeyType, ObjectType>, NSDate, NSData, NSLocale;
  10.  
  11. NS_HEADER_AUDIT_BEGIN(nullability, sendability)
  12.  
  13. NS_SWIFT_SENDABLE // Immutable with no mutable subclasses
  14. @interface NSTimeZone : NSObject <NSCopying, NSSecureCoding>
  15.  
  16. @property (readonly, copy) NSString *name;
  17. @property (readonly, copy) NSData *data;
  18.  
  19. - (NSInteger)secondsFromGMTForDate:(NSDate *)aDate;
  20. - (nullable NSString *)abbreviationForDate:(NSDate *)aDate;
  21. - (BOOL)isDaylightSavingTimeForDate:(NSDate *)aDate;
  22. - (NSTimeInterval)daylightSavingTimeOffsetForDate:(NSDate *)aDate API_AVAILABLE(macos(10.5), ios(2.0), watchos(2.0), tvos(9.0));
  23. - (nullable NSDate *)nextDaylightSavingTimeTransitionAfterDate:(NSDate *)aDate API_AVAILABLE(macos(10.5), ios(2.0), watchos(2.0), tvos(9.0));
  24.  
  25. @end
  26.  
  27. @interface NSTimeZone (NSExtendedTimeZone)
  28.  
  29. @property (class, readonly, copy) NSTimeZone *systemTimeZone;
  30. + (void)resetSystemTimeZone;
  31.  
  32. @property (class, copy) NSTimeZone *defaultTimeZone;
  33.  
  34. @property (class, readonly, copy) NSTimeZone *localTimeZone;
  35.  
  36. @property (class, readonly, copy) NSArray<NSString *> *knownTimeZoneNames;
  37.  
  38. @property (class, copy) NSDictionary<NSString *, NSString *> *abbreviationDictionary API_AVAILABLE(macos(10.6), ios(4.0), watchos(2.0), tvos(9.0));
  39.  
  40. + (NSDictionary<NSString *, NSString *> *)abbreviationDictionary;
  41.  
  42. @property (class, readonly, copy) NSString *timeZoneDataVersion API_AVAILABLE(macos(10.6), ios(4.0), watchos(2.0), tvos(9.0));
  43.  
  44. @property (readonly) NSInteger secondsFromGMT;
  45. @property (nullable, readonly, copy) NSString *abbreviation;
  46. @property (readonly, getter=isDaylightSavingTime) BOOL daylightSavingTime;
  47. @property (readonly) NSTimeInterval daylightSavingTimeOffset API_AVAILABLE(macos(10.5), ios(2.0), watchos(2.0), tvos(9.0)); // for current instant
  48. @property (nullable, readonly, copy) NSDate *nextDaylightSavingTimeTransition API_AVAILABLE(macos(10.5), ios(2.0), watchos(2.0), tvos(9.0)); // after current instant
  49.  
  50. @property (readonly, copy) NSString *description;
  51.  
  52. - (BOOL)isEqualToTimeZone:(NSTimeZone *)aTimeZone;
  53.  
  54. typedef NS_ENUM(NSInteger, NSTimeZoneNameStyle) {
  55.     NSTimeZoneNameStyleStandard,        // Central Standard Time
  56.     NSTimeZoneNameStyleShortStandard,   // CST
  57.     NSTimeZoneNameStyleDaylightSaving,  // Central Daylight Time
  58.     NSTimeZoneNameStyleShortDaylightSaving, // CDT
  59.     NSTimeZoneNameStyleGeneric,     // Central Time
  60.     NSTimeZoneNameStyleShortGeneric     // CT
  61. };
  62.  
  63. - (nullable NSString *)localizedName:(NSTimeZoneNameStyle)style locale:(nullable NSLocale *)locale API_AVAILABLE(macos(10.5), ios(2.0), watchos(2.0), tvos(9.0));
  64.  
  65. @end
  66.  
  67. @interface NSTimeZone (NSTimeZoneCreation)
  68.  
  69. // Primary creation method is +timeZoneWithName:; the
  70. // data-taking variants should rarely be used directly
  71.  
  72. + (nullable instancetype)timeZoneWithName:(NSString *)tzName;
  73. + (nullable instancetype)timeZoneWithName:(NSString *)tzName data:(nullable NSData *)aData;
  74.  
  75. - (nullable instancetype)initWithName:(NSString *)tzName;
  76. - (nullable instancetype)initWithName:(NSString *)tzName data:(nullable NSData *)aData;
  77.  
  78. // Time zones created with this never have daylight savings and the
  79. // offset is constant no matter the date; the name and abbreviation
  80. // do NOT follow the POSIX convention (of minutes-west).
  81. + (instancetype)timeZoneForSecondsFromGMT:(NSInteger)seconds;
  82.  
  83. + (nullable instancetype)timeZoneWithAbbreviation:(NSString *)abbreviation;
  84.  
  85. @end
  86.  
  87. FOUNDATION_EXPORT NSNotificationName const NSSystemTimeZoneDidChangeNotification API_AVAILABLE(macos(10.5), ios(2.0), watchos(2.0), tvos(9.0));
  88.  
  89. NS_HEADER_AUDIT_END(nullability, sendability)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement