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