objc2_foundation/generated/
NSTimeZone.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6
7use crate::*;
8
9extern_class!(
10    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nstimezone?language=objc)
11    #[unsafe(super(NSObject))]
12    #[derive(Debug, PartialEq, Eq, Hash)]
13    pub struct NSTimeZone;
14);
15
16unsafe impl Send for NSTimeZone {}
17
18unsafe impl Sync for NSTimeZone {}
19
20#[cfg(feature = "NSObject")]
21extern_conformance!(
22    unsafe impl NSCoding for NSTimeZone {}
23);
24
25#[cfg(feature = "NSObject")]
26extern_conformance!(
27    unsafe impl NSCopying for NSTimeZone {}
28);
29
30#[cfg(feature = "NSObject")]
31unsafe impl CopyingHelper for NSTimeZone {
32    type Result = Self;
33}
34
35extern_conformance!(
36    unsafe impl NSObjectProtocol for NSTimeZone {}
37);
38
39#[cfg(feature = "NSObject")]
40extern_conformance!(
41    unsafe impl NSSecureCoding for NSTimeZone {}
42);
43
44impl NSTimeZone {
45    extern_methods!(
46        #[cfg(feature = "NSString")]
47        #[unsafe(method(name))]
48        #[unsafe(method_family = none)]
49        pub unsafe fn name(&self) -> Retained<NSString>;
50
51        #[cfg(feature = "NSData")]
52        #[unsafe(method(data))]
53        #[unsafe(method_family = none)]
54        pub unsafe fn data(&self) -> Retained<NSData>;
55
56        #[cfg(feature = "NSDate")]
57        #[unsafe(method(secondsFromGMTForDate:))]
58        #[unsafe(method_family = none)]
59        pub unsafe fn secondsFromGMTForDate(&self, a_date: &NSDate) -> NSInteger;
60
61        #[cfg(all(feature = "NSDate", feature = "NSString"))]
62        #[unsafe(method(abbreviationForDate:))]
63        #[unsafe(method_family = none)]
64        pub unsafe fn abbreviationForDate(&self, a_date: &NSDate) -> Option<Retained<NSString>>;
65
66        #[cfg(feature = "NSDate")]
67        #[unsafe(method(isDaylightSavingTimeForDate:))]
68        #[unsafe(method_family = none)]
69        pub unsafe fn isDaylightSavingTimeForDate(&self, a_date: &NSDate) -> bool;
70
71        #[cfg(feature = "NSDate")]
72        #[unsafe(method(daylightSavingTimeOffsetForDate:))]
73        #[unsafe(method_family = none)]
74        pub unsafe fn daylightSavingTimeOffsetForDate(&self, a_date: &NSDate) -> NSTimeInterval;
75
76        #[cfg(feature = "NSDate")]
77        #[unsafe(method(nextDaylightSavingTimeTransitionAfterDate:))]
78        #[unsafe(method_family = none)]
79        pub unsafe fn nextDaylightSavingTimeTransitionAfterDate(
80            &self,
81            a_date: &NSDate,
82        ) -> Option<Retained<NSDate>>;
83    );
84}
85
86/// Methods declared on superclass `NSObject`.
87impl NSTimeZone {
88    extern_methods!(
89        #[unsafe(method(init))]
90        #[unsafe(method_family = init)]
91        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
92
93        #[unsafe(method(new))]
94        #[unsafe(method_family = new)]
95        pub unsafe fn new() -> Retained<Self>;
96    );
97}
98
99/// [Apple's documentation](https://developer.apple.com/documentation/foundation/nstimezonenamestyle?language=objc)
100// NS_ENUM
101#[repr(transparent)]
102#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
103pub struct NSTimeZoneNameStyle(pub NSInteger);
104impl NSTimeZoneNameStyle {
105    #[doc(alias = "NSTimeZoneNameStyleStandard")]
106    pub const Standard: Self = Self(0);
107    #[doc(alias = "NSTimeZoneNameStyleShortStandard")]
108    pub const ShortStandard: Self = Self(1);
109    #[doc(alias = "NSTimeZoneNameStyleDaylightSaving")]
110    pub const DaylightSaving: Self = Self(2);
111    #[doc(alias = "NSTimeZoneNameStyleShortDaylightSaving")]
112    pub const ShortDaylightSaving: Self = Self(3);
113    #[doc(alias = "NSTimeZoneNameStyleGeneric")]
114    pub const Generic: Self = Self(4);
115    #[doc(alias = "NSTimeZoneNameStyleShortGeneric")]
116    pub const ShortGeneric: Self = Self(5);
117}
118
119unsafe impl Encode for NSTimeZoneNameStyle {
120    const ENCODING: Encoding = NSInteger::ENCODING;
121}
122
123unsafe impl RefEncode for NSTimeZoneNameStyle {
124    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
125}
126
127/// NSExtendedTimeZone.
128impl NSTimeZone {
129    extern_methods!(
130        #[unsafe(method(systemTimeZone))]
131        #[unsafe(method_family = none)]
132        pub unsafe fn systemTimeZone() -> Retained<NSTimeZone>;
133
134        #[unsafe(method(resetSystemTimeZone))]
135        #[unsafe(method_family = none)]
136        pub unsafe fn resetSystemTimeZone();
137
138        #[unsafe(method(defaultTimeZone))]
139        #[unsafe(method_family = none)]
140        pub unsafe fn defaultTimeZone() -> Retained<NSTimeZone>;
141
142        /// Setter for [`defaultTimeZone`][Self::defaultTimeZone].
143        #[unsafe(method(setDefaultTimeZone:))]
144        #[unsafe(method_family = none)]
145        pub unsafe fn setDefaultTimeZone(default_time_zone: &NSTimeZone);
146
147        #[unsafe(method(localTimeZone))]
148        #[unsafe(method_family = none)]
149        pub unsafe fn localTimeZone() -> Retained<NSTimeZone>;
150
151        #[cfg(all(feature = "NSArray", feature = "NSString"))]
152        #[unsafe(method(knownTimeZoneNames))]
153        #[unsafe(method_family = none)]
154        pub unsafe fn knownTimeZoneNames() -> Retained<NSArray<NSString>>;
155
156        #[cfg(all(feature = "NSDictionary", feature = "NSString"))]
157        #[unsafe(method(abbreviationDictionary))]
158        #[unsafe(method_family = none)]
159        pub unsafe fn abbreviationDictionary() -> Retained<NSDictionary<NSString, NSString>>;
160
161        #[cfg(all(feature = "NSDictionary", feature = "NSString"))]
162        /// Setter for [`abbreviationDictionary`][Self::abbreviationDictionary].
163        #[unsafe(method(setAbbreviationDictionary:))]
164        #[unsafe(method_family = none)]
165        pub unsafe fn setAbbreviationDictionary(
166            abbreviation_dictionary: &NSDictionary<NSString, NSString>,
167        );
168
169        #[cfg(feature = "NSString")]
170        #[unsafe(method(timeZoneDataVersion))]
171        #[unsafe(method_family = none)]
172        pub unsafe fn timeZoneDataVersion() -> Retained<NSString>;
173
174        #[unsafe(method(secondsFromGMT))]
175        #[unsafe(method_family = none)]
176        pub unsafe fn secondsFromGMT(&self) -> NSInteger;
177
178        #[cfg(feature = "NSString")]
179        #[unsafe(method(abbreviation))]
180        #[unsafe(method_family = none)]
181        pub unsafe fn abbreviation(&self) -> Option<Retained<NSString>>;
182
183        #[unsafe(method(isDaylightSavingTime))]
184        #[unsafe(method_family = none)]
185        pub unsafe fn isDaylightSavingTime(&self) -> bool;
186
187        #[cfg(feature = "NSDate")]
188        #[unsafe(method(daylightSavingTimeOffset))]
189        #[unsafe(method_family = none)]
190        pub unsafe fn daylightSavingTimeOffset(&self) -> NSTimeInterval;
191
192        #[cfg(feature = "NSDate")]
193        #[unsafe(method(nextDaylightSavingTimeTransition))]
194        #[unsafe(method_family = none)]
195        pub unsafe fn nextDaylightSavingTimeTransition(&self) -> Option<Retained<NSDate>>;
196
197        #[cfg(feature = "NSString")]
198        #[unsafe(method(description))]
199        #[unsafe(method_family = none)]
200        pub unsafe fn description(&self) -> Retained<NSString>;
201
202        #[unsafe(method(isEqualToTimeZone:))]
203        #[unsafe(method_family = none)]
204        pub unsafe fn isEqualToTimeZone(&self, a_time_zone: &NSTimeZone) -> bool;
205
206        #[cfg(all(feature = "NSLocale", feature = "NSString"))]
207        #[unsafe(method(localizedName:locale:))]
208        #[unsafe(method_family = none)]
209        pub unsafe fn localizedName_locale(
210            &self,
211            style: NSTimeZoneNameStyle,
212            locale: Option<&NSLocale>,
213        ) -> Option<Retained<NSString>>;
214    );
215}
216
217/// NSTimeZoneCreation.
218impl NSTimeZone {
219    extern_methods!(
220        #[cfg(feature = "NSString")]
221        #[unsafe(method(timeZoneWithName:))]
222        #[unsafe(method_family = none)]
223        pub unsafe fn timeZoneWithName(tz_name: &NSString) -> Option<Retained<Self>>;
224
225        #[cfg(all(feature = "NSData", feature = "NSString"))]
226        #[unsafe(method(timeZoneWithName:data:))]
227        #[unsafe(method_family = none)]
228        pub unsafe fn timeZoneWithName_data(
229            tz_name: &NSString,
230            a_data: Option<&NSData>,
231        ) -> Option<Retained<Self>>;
232
233        #[cfg(feature = "NSString")]
234        #[unsafe(method(initWithName:))]
235        #[unsafe(method_family = init)]
236        pub unsafe fn initWithName(
237            this: Allocated<Self>,
238            tz_name: &NSString,
239        ) -> Option<Retained<Self>>;
240
241        #[cfg(all(feature = "NSData", feature = "NSString"))]
242        #[unsafe(method(initWithName:data:))]
243        #[unsafe(method_family = init)]
244        pub unsafe fn initWithName_data(
245            this: Allocated<Self>,
246            tz_name: &NSString,
247            a_data: Option<&NSData>,
248        ) -> Option<Retained<Self>>;
249
250        #[unsafe(method(timeZoneForSecondsFromGMT:))]
251        #[unsafe(method_family = none)]
252        pub unsafe fn timeZoneForSecondsFromGMT(seconds: NSInteger) -> Retained<Self>;
253
254        #[cfg(feature = "NSString")]
255        #[unsafe(method(timeZoneWithAbbreviation:))]
256        #[unsafe(method_family = none)]
257        pub unsafe fn timeZoneWithAbbreviation(abbreviation: &NSString) -> Option<Retained<Self>>;
258    );
259}
260
261extern "C" {
262    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nssystemtimezonedidchangenotification?language=objc)
263    #[cfg(all(feature = "NSNotification", feature = "NSString"))]
264    pub static NSSystemTimeZoneDidChangeNotification: &'static NSNotificationName;
265}