objc2_core_foundation/generated/
CFTimeZone.rs1use core::ffi::*;
4use core::ptr::NonNull;
5#[cfg(feature = "objc2")]
6use objc2::__framework_prelude::*;
7
8use crate::*;
9
10#[cfg(feature = "CFDate")]
11unsafe impl ConcreteType for CFTimeZone {
12 #[doc(alias = "CFTimeZoneGetTypeID")]
13 #[inline]
14 fn type_id() -> CFTypeID {
15 extern "C-unwind" {
16 fn CFTimeZoneGetTypeID() -> CFTypeID;
17 }
18 unsafe { CFTimeZoneGetTypeID() }
19 }
20}
21
22#[cfg(feature = "CFDate")]
23impl CFTimeZone {
24 #[doc(alias = "CFTimeZoneCopySystem")]
25 #[cfg(feature = "CFDate")]
26 #[inline]
27 pub fn system() -> Option<CFRetained<CFTimeZone>> {
28 extern "C-unwind" {
29 fn CFTimeZoneCopySystem() -> Option<NonNull<CFTimeZone>>;
30 }
31 let ret = unsafe { CFTimeZoneCopySystem() };
32 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
33 }
34
35 #[doc(alias = "CFTimeZoneResetSystem")]
36 #[inline]
37 pub unsafe fn reset_system() {
38 extern "C-unwind" {
39 fn CFTimeZoneResetSystem();
40 }
41 unsafe { CFTimeZoneResetSystem() }
42 }
43
44 #[doc(alias = "CFTimeZoneCopyDefault")]
45 #[cfg(feature = "CFDate")]
46 #[inline]
47 pub fn default() -> Option<CFRetained<CFTimeZone>> {
48 extern "C-unwind" {
49 fn CFTimeZoneCopyDefault() -> Option<NonNull<CFTimeZone>>;
50 }
51 let ret = unsafe { CFTimeZoneCopyDefault() };
52 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
53 }
54
55 #[doc(alias = "CFTimeZoneSetDefault")]
56 #[cfg(feature = "CFDate")]
57 #[inline]
58 pub fn set_default(self: &CFTimeZone) {
59 extern "C-unwind" {
60 fn CFTimeZoneSetDefault(tz: &CFTimeZone);
61 }
62 unsafe { CFTimeZoneSetDefault(self) }
63 }
64
65 #[doc(alias = "CFTimeZoneCopyKnownNames")]
66 #[cfg(feature = "CFArray")]
67 #[inline]
68 pub fn known_names() -> Option<CFRetained<CFArray>> {
69 extern "C-unwind" {
70 fn CFTimeZoneCopyKnownNames() -> Option<NonNull<CFArray>>;
71 }
72 let ret = unsafe { CFTimeZoneCopyKnownNames() };
73 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
74 }
75
76 #[doc(alias = "CFTimeZoneCopyAbbreviationDictionary")]
77 #[cfg(feature = "CFDictionary")]
78 #[inline]
79 pub fn abbreviation_dictionary() -> Option<CFRetained<CFDictionary>> {
80 extern "C-unwind" {
81 fn CFTimeZoneCopyAbbreviationDictionary() -> Option<NonNull<CFDictionary>>;
82 }
83 let ret = unsafe { CFTimeZoneCopyAbbreviationDictionary() };
84 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
85 }
86
87 #[doc(alias = "CFTimeZoneSetAbbreviationDictionary")]
88 #[cfg(feature = "CFDictionary")]
89 #[inline]
90 pub unsafe fn set_abbreviation_dictionary(dict: Option<&CFDictionary>) {
91 extern "C-unwind" {
92 fn CFTimeZoneSetAbbreviationDictionary(dict: Option<&CFDictionary>);
93 }
94 unsafe { CFTimeZoneSetAbbreviationDictionary(dict) }
95 }
96
97 #[doc(alias = "CFTimeZoneCreate")]
98 #[cfg(all(feature = "CFData", feature = "CFDate"))]
99 #[inline]
100 pub unsafe fn new(
101 allocator: Option<&CFAllocator>,
102 name: Option<&CFString>,
103 data: Option<&CFData>,
104 ) -> Option<CFRetained<CFTimeZone>> {
105 extern "C-unwind" {
106 fn CFTimeZoneCreate(
107 allocator: Option<&CFAllocator>,
108 name: Option<&CFString>,
109 data: Option<&CFData>,
110 ) -> Option<NonNull<CFTimeZone>>;
111 }
112 let ret = unsafe { CFTimeZoneCreate(allocator, name, data) };
113 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
114 }
115
116 #[doc(alias = "CFTimeZoneCreateWithTimeIntervalFromGMT")]
117 #[cfg(feature = "CFDate")]
118 #[inline]
119 pub fn with_time_interval_from_gmt(
120 allocator: Option<&CFAllocator>,
121 ti: CFTimeInterval,
122 ) -> Option<CFRetained<CFTimeZone>> {
123 extern "C-unwind" {
124 fn CFTimeZoneCreateWithTimeIntervalFromGMT(
125 allocator: Option<&CFAllocator>,
126 ti: CFTimeInterval,
127 ) -> Option<NonNull<CFTimeZone>>;
128 }
129 let ret = unsafe { CFTimeZoneCreateWithTimeIntervalFromGMT(allocator, ti) };
130 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
131 }
132
133 #[doc(alias = "CFTimeZoneCreateWithName")]
134 #[cfg(feature = "CFDate")]
135 #[inline]
136 pub fn with_name(
137 allocator: Option<&CFAllocator>,
138 name: Option<&CFString>,
139 try_abbrev: bool,
140 ) -> Option<CFRetained<CFTimeZone>> {
141 extern "C-unwind" {
142 fn CFTimeZoneCreateWithName(
143 allocator: Option<&CFAllocator>,
144 name: Option<&CFString>,
145 try_abbrev: Boolean,
146 ) -> Option<NonNull<CFTimeZone>>;
147 }
148 let ret = unsafe { CFTimeZoneCreateWithName(allocator, name, try_abbrev as _) };
149 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
150 }
151
152 #[doc(alias = "CFTimeZoneGetName")]
153 #[cfg(feature = "CFDate")]
154 #[inline]
155 pub fn name(self: &CFTimeZone) -> Option<CFRetained<CFString>> {
156 extern "C-unwind" {
157 fn CFTimeZoneGetName(tz: &CFTimeZone) -> Option<NonNull<CFString>>;
158 }
159 let ret = unsafe { CFTimeZoneGetName(self) };
160 ret.map(|ret| unsafe { CFRetained::retain(ret) })
161 }
162
163 #[doc(alias = "CFTimeZoneGetData")]
164 #[cfg(all(feature = "CFData", feature = "CFDate"))]
165 #[inline]
166 pub fn data(self: &CFTimeZone) -> Option<CFRetained<CFData>> {
167 extern "C-unwind" {
168 fn CFTimeZoneGetData(tz: &CFTimeZone) -> Option<NonNull<CFData>>;
169 }
170 let ret = unsafe { CFTimeZoneGetData(self) };
171 ret.map(|ret| unsafe { CFRetained::retain(ret) })
172 }
173
174 #[doc(alias = "CFTimeZoneGetSecondsFromGMT")]
175 #[cfg(feature = "CFDate")]
176 #[inline]
177 pub fn seconds_from_gmt(self: &CFTimeZone, at: CFAbsoluteTime) -> CFTimeInterval {
178 extern "C-unwind" {
179 fn CFTimeZoneGetSecondsFromGMT(tz: &CFTimeZone, at: CFAbsoluteTime) -> CFTimeInterval;
180 }
181 unsafe { CFTimeZoneGetSecondsFromGMT(self, at) }
182 }
183
184 #[doc(alias = "CFTimeZoneCopyAbbreviation")]
185 #[cfg(feature = "CFDate")]
186 #[inline]
187 pub fn abbreviation(self: &CFTimeZone, at: CFAbsoluteTime) -> Option<CFRetained<CFString>> {
188 extern "C-unwind" {
189 fn CFTimeZoneCopyAbbreviation(
190 tz: &CFTimeZone,
191 at: CFAbsoluteTime,
192 ) -> Option<NonNull<CFString>>;
193 }
194 let ret = unsafe { CFTimeZoneCopyAbbreviation(self, at) };
195 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
196 }
197
198 #[doc(alias = "CFTimeZoneIsDaylightSavingTime")]
199 #[cfg(feature = "CFDate")]
200 #[inline]
201 pub fn is_daylight_saving_time(self: &CFTimeZone, at: CFAbsoluteTime) -> bool {
202 extern "C-unwind" {
203 fn CFTimeZoneIsDaylightSavingTime(tz: &CFTimeZone, at: CFAbsoluteTime) -> Boolean;
204 }
205 let ret = unsafe { CFTimeZoneIsDaylightSavingTime(self, at) };
206 ret != 0
207 }
208
209 #[doc(alias = "CFTimeZoneGetDaylightSavingTimeOffset")]
210 #[cfg(feature = "CFDate")]
211 #[inline]
212 pub fn daylight_saving_time_offset(self: &CFTimeZone, at: CFAbsoluteTime) -> CFTimeInterval {
213 extern "C-unwind" {
214 fn CFTimeZoneGetDaylightSavingTimeOffset(
215 tz: &CFTimeZone,
216 at: CFAbsoluteTime,
217 ) -> CFTimeInterval;
218 }
219 unsafe { CFTimeZoneGetDaylightSavingTimeOffset(self, at) }
220 }
221
222 #[doc(alias = "CFTimeZoneGetNextDaylightSavingTimeTransition")]
223 #[cfg(feature = "CFDate")]
224 #[inline]
225 pub fn next_daylight_saving_time_transition(
226 self: &CFTimeZone,
227 at: CFAbsoluteTime,
228 ) -> CFAbsoluteTime {
229 extern "C-unwind" {
230 fn CFTimeZoneGetNextDaylightSavingTimeTransition(
231 tz: &CFTimeZone,
232 at: CFAbsoluteTime,
233 ) -> CFAbsoluteTime;
234 }
235 unsafe { CFTimeZoneGetNextDaylightSavingTimeTransition(self, at) }
236 }
237}
238
239#[repr(transparent)]
242#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
243pub struct CFTimeZoneNameStyle(pub CFIndex);
244impl CFTimeZoneNameStyle {
245 #[doc(alias = "kCFTimeZoneNameStyleStandard")]
246 pub const Standard: Self = Self(0);
247 #[doc(alias = "kCFTimeZoneNameStyleShortStandard")]
248 pub const ShortStandard: Self = Self(1);
249 #[doc(alias = "kCFTimeZoneNameStyleDaylightSaving")]
250 pub const DaylightSaving: Self = Self(2);
251 #[doc(alias = "kCFTimeZoneNameStyleShortDaylightSaving")]
252 pub const ShortDaylightSaving: Self = Self(3);
253 #[doc(alias = "kCFTimeZoneNameStyleGeneric")]
254 pub const Generic: Self = Self(4);
255 #[doc(alias = "kCFTimeZoneNameStyleShortGeneric")]
256 pub const ShortGeneric: Self = Self(5);
257}
258
259#[cfg(feature = "objc2")]
260unsafe impl Encode for CFTimeZoneNameStyle {
261 const ENCODING: Encoding = CFIndex::ENCODING;
262}
263
264#[cfg(feature = "objc2")]
265unsafe impl RefEncode for CFTimeZoneNameStyle {
266 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
267}
268
269#[cfg(feature = "CFDate")]
270impl CFTimeZone {
271 #[doc(alias = "CFTimeZoneCopyLocalizedName")]
272 #[cfg(all(feature = "CFDate", feature = "CFLocale"))]
273 #[inline]
274 pub fn localized_name(
275 self: &CFTimeZone,
276 style: CFTimeZoneNameStyle,
277 locale: Option<&CFLocale>,
278 ) -> Option<CFRetained<CFString>> {
279 extern "C-unwind" {
280 fn CFTimeZoneCopyLocalizedName(
281 tz: &CFTimeZone,
282 style: CFTimeZoneNameStyle,
283 locale: Option<&CFLocale>,
284 ) -> Option<NonNull<CFString>>;
285 }
286 let ret = unsafe { CFTimeZoneCopyLocalizedName(self, style, locale) };
287 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
288 }
289}
290
291extern "C" {
292 #[cfg(feature = "CFNotificationCenter")]
294 pub static kCFTimeZoneSystemTimeZoneDidChangeNotification: Option<&'static CFNotificationName>;
295}
296
297#[cfg(feature = "CFDate")]
298#[deprecated = "renamed to `CFTimeZone::system`"]
299#[inline]
300pub extern "C-unwind" fn CFTimeZoneCopySystem() -> Option<CFRetained<CFTimeZone>> {
301 extern "C-unwind" {
302 fn CFTimeZoneCopySystem() -> Option<NonNull<CFTimeZone>>;
303 }
304 let ret = unsafe { CFTimeZoneCopySystem() };
305 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
306}
307
308extern "C-unwind" {
309 #[deprecated = "renamed to `CFTimeZone::reset_system`"]
310 pub fn CFTimeZoneResetSystem();
311}
312
313#[cfg(feature = "CFDate")]
314#[deprecated = "renamed to `CFTimeZone::default`"]
315#[inline]
316pub extern "C-unwind" fn CFTimeZoneCopyDefault() -> Option<CFRetained<CFTimeZone>> {
317 extern "C-unwind" {
318 fn CFTimeZoneCopyDefault() -> Option<NonNull<CFTimeZone>>;
319 }
320 let ret = unsafe { CFTimeZoneCopyDefault() };
321 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
322}
323
324#[cfg(feature = "CFDate")]
325#[deprecated = "renamed to `CFTimeZone::set_default`"]
326#[inline]
327pub extern "C-unwind" fn CFTimeZoneSetDefault(tz: &CFTimeZone) {
328 extern "C-unwind" {
329 fn CFTimeZoneSetDefault(tz: &CFTimeZone);
330 }
331 unsafe { CFTimeZoneSetDefault(tz) }
332}
333
334#[cfg(feature = "CFArray")]
335#[deprecated = "renamed to `CFTimeZone::known_names`"]
336#[inline]
337pub extern "C-unwind" fn CFTimeZoneCopyKnownNames() -> Option<CFRetained<CFArray>> {
338 extern "C-unwind" {
339 fn CFTimeZoneCopyKnownNames() -> Option<NonNull<CFArray>>;
340 }
341 let ret = unsafe { CFTimeZoneCopyKnownNames() };
342 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
343}
344
345#[cfg(feature = "CFDictionary")]
346#[deprecated = "renamed to `CFTimeZone::abbreviation_dictionary`"]
347#[inline]
348pub extern "C-unwind" fn CFTimeZoneCopyAbbreviationDictionary() -> Option<CFRetained<CFDictionary>>
349{
350 extern "C-unwind" {
351 fn CFTimeZoneCopyAbbreviationDictionary() -> Option<NonNull<CFDictionary>>;
352 }
353 let ret = unsafe { CFTimeZoneCopyAbbreviationDictionary() };
354 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
355}
356
357extern "C-unwind" {
358 #[cfg(feature = "CFDictionary")]
359 #[deprecated = "renamed to `CFTimeZone::set_abbreviation_dictionary`"]
360 pub fn CFTimeZoneSetAbbreviationDictionary(dict: Option<&CFDictionary>);
361}
362
363#[cfg(all(feature = "CFData", feature = "CFDate"))]
364#[deprecated = "renamed to `CFTimeZone::new`"]
365#[inline]
366pub unsafe extern "C-unwind" fn CFTimeZoneCreate(
367 allocator: Option<&CFAllocator>,
368 name: Option<&CFString>,
369 data: Option<&CFData>,
370) -> Option<CFRetained<CFTimeZone>> {
371 extern "C-unwind" {
372 fn CFTimeZoneCreate(
373 allocator: Option<&CFAllocator>,
374 name: Option<&CFString>,
375 data: Option<&CFData>,
376 ) -> Option<NonNull<CFTimeZone>>;
377 }
378 let ret = unsafe { CFTimeZoneCreate(allocator, name, data) };
379 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
380}
381
382#[cfg(feature = "CFDate")]
383#[deprecated = "renamed to `CFTimeZone::with_time_interval_from_gmt`"]
384#[inline]
385pub extern "C-unwind" fn CFTimeZoneCreateWithTimeIntervalFromGMT(
386 allocator: Option<&CFAllocator>,
387 ti: CFTimeInterval,
388) -> Option<CFRetained<CFTimeZone>> {
389 extern "C-unwind" {
390 fn CFTimeZoneCreateWithTimeIntervalFromGMT(
391 allocator: Option<&CFAllocator>,
392 ti: CFTimeInterval,
393 ) -> Option<NonNull<CFTimeZone>>;
394 }
395 let ret = unsafe { CFTimeZoneCreateWithTimeIntervalFromGMT(allocator, ti) };
396 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
397}
398
399#[cfg(feature = "CFDate")]
400#[deprecated = "renamed to `CFTimeZone::with_name`"]
401#[inline]
402pub extern "C-unwind" fn CFTimeZoneCreateWithName(
403 allocator: Option<&CFAllocator>,
404 name: Option<&CFString>,
405 try_abbrev: bool,
406) -> Option<CFRetained<CFTimeZone>> {
407 extern "C-unwind" {
408 fn CFTimeZoneCreateWithName(
409 allocator: Option<&CFAllocator>,
410 name: Option<&CFString>,
411 try_abbrev: Boolean,
412 ) -> Option<NonNull<CFTimeZone>>;
413 }
414 let ret = unsafe { CFTimeZoneCreateWithName(allocator, name, try_abbrev as _) };
415 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
416}
417
418#[cfg(feature = "CFDate")]
419#[deprecated = "renamed to `CFTimeZone::name`"]
420#[inline]
421pub extern "C-unwind" fn CFTimeZoneGetName(tz: &CFTimeZone) -> Option<CFRetained<CFString>> {
422 extern "C-unwind" {
423 fn CFTimeZoneGetName(tz: &CFTimeZone) -> Option<NonNull<CFString>>;
424 }
425 let ret = unsafe { CFTimeZoneGetName(tz) };
426 ret.map(|ret| unsafe { CFRetained::retain(ret) })
427}
428
429#[cfg(all(feature = "CFData", feature = "CFDate"))]
430#[deprecated = "renamed to `CFTimeZone::data`"]
431#[inline]
432pub extern "C-unwind" fn CFTimeZoneGetData(tz: &CFTimeZone) -> Option<CFRetained<CFData>> {
433 extern "C-unwind" {
434 fn CFTimeZoneGetData(tz: &CFTimeZone) -> Option<NonNull<CFData>>;
435 }
436 let ret = unsafe { CFTimeZoneGetData(tz) };
437 ret.map(|ret| unsafe { CFRetained::retain(ret) })
438}
439
440#[cfg(feature = "CFDate")]
441#[deprecated = "renamed to `CFTimeZone::seconds_from_gmt`"]
442#[inline]
443pub extern "C-unwind" fn CFTimeZoneGetSecondsFromGMT(
444 tz: &CFTimeZone,
445 at: CFAbsoluteTime,
446) -> CFTimeInterval {
447 extern "C-unwind" {
448 fn CFTimeZoneGetSecondsFromGMT(tz: &CFTimeZone, at: CFAbsoluteTime) -> CFTimeInterval;
449 }
450 unsafe { CFTimeZoneGetSecondsFromGMT(tz, at) }
451}
452
453#[cfg(feature = "CFDate")]
454#[deprecated = "renamed to `CFTimeZone::abbreviation`"]
455#[inline]
456pub extern "C-unwind" fn CFTimeZoneCopyAbbreviation(
457 tz: &CFTimeZone,
458 at: CFAbsoluteTime,
459) -> Option<CFRetained<CFString>> {
460 extern "C-unwind" {
461 fn CFTimeZoneCopyAbbreviation(
462 tz: &CFTimeZone,
463 at: CFAbsoluteTime,
464 ) -> Option<NonNull<CFString>>;
465 }
466 let ret = unsafe { CFTimeZoneCopyAbbreviation(tz, at) };
467 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
468}
469
470#[cfg(feature = "CFDate")]
471#[deprecated = "renamed to `CFTimeZone::is_daylight_saving_time`"]
472#[inline]
473pub extern "C-unwind" fn CFTimeZoneIsDaylightSavingTime(
474 tz: &CFTimeZone,
475 at: CFAbsoluteTime,
476) -> bool {
477 extern "C-unwind" {
478 fn CFTimeZoneIsDaylightSavingTime(tz: &CFTimeZone, at: CFAbsoluteTime) -> Boolean;
479 }
480 let ret = unsafe { CFTimeZoneIsDaylightSavingTime(tz, at) };
481 ret != 0
482}
483
484#[cfg(feature = "CFDate")]
485#[deprecated = "renamed to `CFTimeZone::daylight_saving_time_offset`"]
486#[inline]
487pub extern "C-unwind" fn CFTimeZoneGetDaylightSavingTimeOffset(
488 tz: &CFTimeZone,
489 at: CFAbsoluteTime,
490) -> CFTimeInterval {
491 extern "C-unwind" {
492 fn CFTimeZoneGetDaylightSavingTimeOffset(
493 tz: &CFTimeZone,
494 at: CFAbsoluteTime,
495 ) -> CFTimeInterval;
496 }
497 unsafe { CFTimeZoneGetDaylightSavingTimeOffset(tz, at) }
498}
499
500#[cfg(feature = "CFDate")]
501#[deprecated = "renamed to `CFTimeZone::next_daylight_saving_time_transition`"]
502#[inline]
503pub extern "C-unwind" fn CFTimeZoneGetNextDaylightSavingTimeTransition(
504 tz: &CFTimeZone,
505 at: CFAbsoluteTime,
506) -> CFAbsoluteTime {
507 extern "C-unwind" {
508 fn CFTimeZoneGetNextDaylightSavingTimeTransition(
509 tz: &CFTimeZone,
510 at: CFAbsoluteTime,
511 ) -> CFAbsoluteTime;
512 }
513 unsafe { CFTimeZoneGetNextDaylightSavingTimeTransition(tz, at) }
514}
515
516#[cfg(all(feature = "CFDate", feature = "CFLocale"))]
517#[deprecated = "renamed to `CFTimeZone::localized_name`"]
518#[inline]
519pub extern "C-unwind" fn CFTimeZoneCopyLocalizedName(
520 tz: &CFTimeZone,
521 style: CFTimeZoneNameStyle,
522 locale: Option<&CFLocale>,
523) -> Option<CFRetained<CFString>> {
524 extern "C-unwind" {
525 fn CFTimeZoneCopyLocalizedName(
526 tz: &CFTimeZone,
527 style: CFTimeZoneNameStyle,
528 locale: Option<&CFLocale>,
529 ) -> Option<NonNull<CFString>>;
530 }
531 let ret = unsafe { CFTimeZoneCopyLocalizedName(tz, style, locale) };
532 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
533}