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