objc2_core_foundation/generated/
CFDateFormatter.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::cell::UnsafeCell;
4use core::ffi::*;
5use core::marker::{PhantomData, PhantomPinned};
6use core::ptr::NonNull;
7#[cfg(feature = "objc2")]
8use objc2::__framework_prelude::*;
9
10use crate::*;
11
12/// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/cfdateformatterkey?language=objc)
13// NS_TYPED_ENUM
14#[cfg(feature = "CFBase")]
15pub type CFDateFormatterKey = CFString;
16
17/// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/cfdateformatter?language=objc)
18#[repr(C)]
19pub struct CFDateFormatter {
20    inner: [u8; 0],
21    _p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
22}
23
24cf_type!(
25    #[encoding_name = "__CFDateFormatter"]
26    unsafe impl CFDateFormatter {}
27);
28
29#[cfg(all(feature = "CFBase", feature = "CFLocale"))]
30#[inline]
31pub unsafe extern "C-unwind" fn CFDateFormatterCreateDateFormatFromTemplate(
32    allocator: Option<&CFAllocator>,
33    tmplate: Option<&CFString>,
34    options: CFOptionFlags,
35    locale: Option<&CFLocale>,
36) -> Option<CFRetained<CFString>> {
37    extern "C-unwind" {
38        fn CFDateFormatterCreateDateFormatFromTemplate(
39            allocator: Option<&CFAllocator>,
40            tmplate: Option<&CFString>,
41            options: CFOptionFlags,
42            locale: Option<&CFLocale>,
43        ) -> Option<NonNull<CFString>>;
44    }
45    let ret =
46        unsafe { CFDateFormatterCreateDateFormatFromTemplate(allocator, tmplate, options, locale) };
47    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
48}
49
50#[cfg(feature = "CFBase")]
51unsafe impl ConcreteType for CFDateFormatter {
52    #[doc(alias = "CFDateFormatterGetTypeID")]
53    #[inline]
54    fn type_id() -> CFTypeID {
55        extern "C-unwind" {
56            fn CFDateFormatterGetTypeID() -> CFTypeID;
57        }
58        unsafe { CFDateFormatterGetTypeID() }
59    }
60}
61
62/// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/cfdateformatterstyle?language=objc)
63// NS_ENUM
64#[cfg(feature = "CFBase")]
65#[repr(transparent)]
66#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
67pub struct CFDateFormatterStyle(pub CFIndex);
68#[cfg(feature = "CFBase")]
69impl CFDateFormatterStyle {
70    #[doc(alias = "kCFDateFormatterNoStyle")]
71    pub const NoStyle: Self = Self(0);
72    #[doc(alias = "kCFDateFormatterShortStyle")]
73    pub const ShortStyle: Self = Self(1);
74    #[doc(alias = "kCFDateFormatterMediumStyle")]
75    pub const MediumStyle: Self = Self(2);
76    #[doc(alias = "kCFDateFormatterLongStyle")]
77    pub const LongStyle: Self = Self(3);
78    #[doc(alias = "kCFDateFormatterFullStyle")]
79    pub const FullStyle: Self = Self(4);
80}
81
82#[cfg(all(feature = "CFBase", feature = "objc2"))]
83unsafe impl Encode for CFDateFormatterStyle {
84    const ENCODING: Encoding = CFIndex::ENCODING;
85}
86
87#[cfg(all(feature = "CFBase", feature = "objc2"))]
88unsafe impl RefEncode for CFDateFormatterStyle {
89    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
90}
91
92/// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/cfiso8601dateformatoptions?language=objc)
93// NS_OPTIONS
94#[cfg(feature = "CFBase")]
95#[repr(transparent)]
96#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
97pub struct CFISO8601DateFormatOptions(pub CFOptionFlags);
98#[cfg(feature = "CFBase")]
99bitflags::bitflags! {
100    impl CFISO8601DateFormatOptions: CFOptionFlags {
101        #[doc(alias = "kCFISO8601DateFormatWithYear")]
102        const WithYear = 1<<0;
103        #[doc(alias = "kCFISO8601DateFormatWithMonth")]
104        const WithMonth = 1<<1;
105        #[doc(alias = "kCFISO8601DateFormatWithWeekOfYear")]
106        const WithWeekOfYear = 1<<2;
107        #[doc(alias = "kCFISO8601DateFormatWithDay")]
108        const WithDay = 1<<4;
109        #[doc(alias = "kCFISO8601DateFormatWithTime")]
110        const WithTime = 1<<5;
111        #[doc(alias = "kCFISO8601DateFormatWithTimeZone")]
112        const WithTimeZone = 1<<6;
113        #[doc(alias = "kCFISO8601DateFormatWithSpaceBetweenDateAndTime")]
114        const WithSpaceBetweenDateAndTime = 1<<7;
115        #[doc(alias = "kCFISO8601DateFormatWithDashSeparatorInDate")]
116        const WithDashSeparatorInDate = 1<<8;
117        #[doc(alias = "kCFISO8601DateFormatWithColonSeparatorInTime")]
118        const WithColonSeparatorInTime = 1<<9;
119        #[doc(alias = "kCFISO8601DateFormatWithColonSeparatorInTimeZone")]
120        const WithColonSeparatorInTimeZone = 1<<10;
121        #[doc(alias = "kCFISO8601DateFormatWithFractionalSeconds")]
122        const WithFractionalSeconds = 1<<11;
123        #[doc(alias = "kCFISO8601DateFormatWithFullDate")]
124        const WithFullDate = CFISO8601DateFormatOptions::WithYear.0|CFISO8601DateFormatOptions::WithMonth.0|CFISO8601DateFormatOptions::WithDay.0|CFISO8601DateFormatOptions::WithDashSeparatorInDate.0;
125        #[doc(alias = "kCFISO8601DateFormatWithFullTime")]
126        const WithFullTime = CFISO8601DateFormatOptions::WithTime.0|CFISO8601DateFormatOptions::WithColonSeparatorInTime.0|CFISO8601DateFormatOptions::WithTimeZone.0|CFISO8601DateFormatOptions::WithColonSeparatorInTimeZone.0;
127        #[doc(alias = "kCFISO8601DateFormatWithInternetDateTime")]
128        const WithInternetDateTime = CFISO8601DateFormatOptions::WithFullDate.0|CFISO8601DateFormatOptions::WithFullTime.0;
129    }
130}
131
132#[cfg(all(feature = "CFBase", feature = "objc2"))]
133unsafe impl Encode for CFISO8601DateFormatOptions {
134    const ENCODING: Encoding = CFOptionFlags::ENCODING;
135}
136
137#[cfg(all(feature = "CFBase", feature = "objc2"))]
138unsafe impl RefEncode for CFISO8601DateFormatOptions {
139    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
140}
141
142#[cfg(feature = "CFBase")]
143#[inline]
144pub unsafe extern "C-unwind" fn CFDateFormatterCreateISO8601Formatter(
145    allocator: Option<&CFAllocator>,
146    format_options: CFISO8601DateFormatOptions,
147) -> Option<CFRetained<CFDateFormatter>> {
148    extern "C-unwind" {
149        fn CFDateFormatterCreateISO8601Formatter(
150            allocator: Option<&CFAllocator>,
151            format_options: CFISO8601DateFormatOptions,
152        ) -> Option<NonNull<CFDateFormatter>>;
153    }
154    let ret = unsafe { CFDateFormatterCreateISO8601Formatter(allocator, format_options) };
155    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
156}
157
158#[cfg(all(feature = "CFBase", feature = "CFLocale"))]
159#[inline]
160pub unsafe extern "C-unwind" fn CFDateFormatterCreate(
161    allocator: Option<&CFAllocator>,
162    locale: Option<&CFLocale>,
163    date_style: CFDateFormatterStyle,
164    time_style: CFDateFormatterStyle,
165) -> Option<CFRetained<CFDateFormatter>> {
166    extern "C-unwind" {
167        fn CFDateFormatterCreate(
168            allocator: Option<&CFAllocator>,
169            locale: Option<&CFLocale>,
170            date_style: CFDateFormatterStyle,
171            time_style: CFDateFormatterStyle,
172        ) -> Option<NonNull<CFDateFormatter>>;
173    }
174    let ret = unsafe { CFDateFormatterCreate(allocator, locale, date_style, time_style) };
175    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
176}
177
178#[cfg(feature = "CFLocale")]
179#[inline]
180pub unsafe extern "C-unwind" fn CFDateFormatterGetLocale(
181    formatter: &CFDateFormatter,
182) -> Option<CFRetained<CFLocale>> {
183    extern "C-unwind" {
184        fn CFDateFormatterGetLocale(formatter: &CFDateFormatter) -> Option<NonNull<CFLocale>>;
185    }
186    let ret = unsafe { CFDateFormatterGetLocale(formatter) };
187    ret.map(|ret| unsafe { CFRetained::retain(ret) })
188}
189
190extern "C-unwind" {
191    #[cfg(feature = "CFBase")]
192    pub fn CFDateFormatterGetDateStyle(formatter: &CFDateFormatter) -> CFDateFormatterStyle;
193}
194
195extern "C-unwind" {
196    #[cfg(feature = "CFBase")]
197    pub fn CFDateFormatterGetTimeStyle(formatter: &CFDateFormatter) -> CFDateFormatterStyle;
198}
199
200#[cfg(feature = "CFBase")]
201#[inline]
202pub unsafe extern "C-unwind" fn CFDateFormatterGetFormat(
203    formatter: &CFDateFormatter,
204) -> Option<CFRetained<CFString>> {
205    extern "C-unwind" {
206        fn CFDateFormatterGetFormat(formatter: &CFDateFormatter) -> Option<NonNull<CFString>>;
207    }
208    let ret = unsafe { CFDateFormatterGetFormat(formatter) };
209    ret.map(|ret| unsafe { CFRetained::retain(ret) })
210}
211
212extern "C-unwind" {
213    #[cfg(feature = "CFBase")]
214    pub fn CFDateFormatterSetFormat(formatter: &CFDateFormatter, format_string: Option<&CFString>);
215}
216
217#[cfg(all(feature = "CFBase", feature = "CFDate"))]
218#[inline]
219pub unsafe extern "C-unwind" fn CFDateFormatterCreateStringWithDate(
220    allocator: Option<&CFAllocator>,
221    formatter: Option<&CFDateFormatter>,
222    date: Option<&CFDate>,
223) -> Option<CFRetained<CFString>> {
224    extern "C-unwind" {
225        fn CFDateFormatterCreateStringWithDate(
226            allocator: Option<&CFAllocator>,
227            formatter: Option<&CFDateFormatter>,
228            date: Option<&CFDate>,
229        ) -> Option<NonNull<CFString>>;
230    }
231    let ret = unsafe { CFDateFormatterCreateStringWithDate(allocator, formatter, date) };
232    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
233}
234
235#[cfg(all(feature = "CFBase", feature = "CFDate"))]
236#[inline]
237pub unsafe extern "C-unwind" fn CFDateFormatterCreateStringWithAbsoluteTime(
238    allocator: Option<&CFAllocator>,
239    formatter: Option<&CFDateFormatter>,
240    at: CFAbsoluteTime,
241) -> Option<CFRetained<CFString>> {
242    extern "C-unwind" {
243        fn CFDateFormatterCreateStringWithAbsoluteTime(
244            allocator: Option<&CFAllocator>,
245            formatter: Option<&CFDateFormatter>,
246            at: CFAbsoluteTime,
247        ) -> Option<NonNull<CFString>>;
248    }
249    let ret = unsafe { CFDateFormatterCreateStringWithAbsoluteTime(allocator, formatter, at) };
250    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
251}
252
253#[cfg(all(feature = "CFBase", feature = "CFDate"))]
254#[inline]
255pub unsafe extern "C-unwind" fn CFDateFormatterCreateDateFromString(
256    allocator: Option<&CFAllocator>,
257    formatter: Option<&CFDateFormatter>,
258    string: Option<&CFString>,
259    rangep: *mut CFRange,
260) -> Option<CFRetained<CFDate>> {
261    extern "C-unwind" {
262        fn CFDateFormatterCreateDateFromString(
263            allocator: Option<&CFAllocator>,
264            formatter: Option<&CFDateFormatter>,
265            string: Option<&CFString>,
266            rangep: *mut CFRange,
267        ) -> Option<NonNull<CFDate>>;
268    }
269    let ret = unsafe { CFDateFormatterCreateDateFromString(allocator, formatter, string, rangep) };
270    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
271}
272
273#[cfg(all(feature = "CFBase", feature = "CFDate"))]
274#[inline]
275pub unsafe extern "C-unwind" fn CFDateFormatterGetAbsoluteTimeFromString(
276    formatter: &CFDateFormatter,
277    string: Option<&CFString>,
278    rangep: *mut CFRange,
279    atp: *mut CFAbsoluteTime,
280) -> bool {
281    extern "C-unwind" {
282        fn CFDateFormatterGetAbsoluteTimeFromString(
283            formatter: &CFDateFormatter,
284            string: Option<&CFString>,
285            rangep: *mut CFRange,
286            atp: *mut CFAbsoluteTime,
287        ) -> Boolean;
288    }
289    let ret = unsafe { CFDateFormatterGetAbsoluteTimeFromString(formatter, string, rangep, atp) };
290    ret != 0
291}
292
293extern "C-unwind" {
294    #[cfg(feature = "CFBase")]
295    pub fn CFDateFormatterSetProperty(
296        formatter: &CFDateFormatter,
297        key: Option<&CFString>,
298        value: Option<&CFType>,
299    );
300}
301
302#[cfg(feature = "CFBase")]
303#[inline]
304pub unsafe extern "C-unwind" fn CFDateFormatterCopyProperty(
305    formatter: &CFDateFormatter,
306    key: Option<&CFDateFormatterKey>,
307) -> Option<CFRetained<CFType>> {
308    extern "C-unwind" {
309        fn CFDateFormatterCopyProperty(
310            formatter: &CFDateFormatter,
311            key: Option<&CFDateFormatterKey>,
312        ) -> Option<NonNull<CFType>>;
313    }
314    let ret = unsafe { CFDateFormatterCopyProperty(formatter, key) };
315    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
316}
317
318extern "C" {
319    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfdateformatterislenient?language=objc)
320    #[cfg(feature = "CFBase")]
321    pub static kCFDateFormatterIsLenient: Option<&'static CFDateFormatterKey>;
322}
323
324extern "C" {
325    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfdateformattertimezone?language=objc)
326    #[cfg(feature = "CFBase")]
327    pub static kCFDateFormatterTimeZone: Option<&'static CFDateFormatterKey>;
328}
329
330extern "C" {
331    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfdateformattercalendarname?language=objc)
332    #[cfg(feature = "CFBase")]
333    pub static kCFDateFormatterCalendarName: Option<&'static CFDateFormatterKey>;
334}
335
336extern "C" {
337    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfdateformatterdefaultformat?language=objc)
338    #[cfg(feature = "CFBase")]
339    pub static kCFDateFormatterDefaultFormat: Option<&'static CFDateFormatterKey>;
340}
341
342extern "C" {
343    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfdateformattertwodigitstartdate?language=objc)
344    #[cfg(feature = "CFBase")]
345    pub static kCFDateFormatterTwoDigitStartDate: Option<&'static CFDateFormatterKey>;
346}
347
348extern "C" {
349    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfdateformatterdefaultdate?language=objc)
350    #[cfg(feature = "CFBase")]
351    pub static kCFDateFormatterDefaultDate: Option<&'static CFDateFormatterKey>;
352}
353
354extern "C" {
355    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfdateformattercalendar?language=objc)
356    #[cfg(feature = "CFBase")]
357    pub static kCFDateFormatterCalendar: Option<&'static CFDateFormatterKey>;
358}
359
360extern "C" {
361    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfdateformattererasymbols?language=objc)
362    #[cfg(feature = "CFBase")]
363    pub static kCFDateFormatterEraSymbols: Option<&'static CFDateFormatterKey>;
364}
365
366extern "C" {
367    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfdateformattermonthsymbols?language=objc)
368    #[cfg(feature = "CFBase")]
369    pub static kCFDateFormatterMonthSymbols: Option<&'static CFDateFormatterKey>;
370}
371
372extern "C" {
373    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfdateformattershortmonthsymbols?language=objc)
374    #[cfg(feature = "CFBase")]
375    pub static kCFDateFormatterShortMonthSymbols: Option<&'static CFDateFormatterKey>;
376}
377
378extern "C" {
379    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfdateformatterweekdaysymbols?language=objc)
380    #[cfg(feature = "CFBase")]
381    pub static kCFDateFormatterWeekdaySymbols: Option<&'static CFDateFormatterKey>;
382}
383
384extern "C" {
385    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfdateformattershortweekdaysymbols?language=objc)
386    #[cfg(feature = "CFBase")]
387    pub static kCFDateFormatterShortWeekdaySymbols: Option<&'static CFDateFormatterKey>;
388}
389
390extern "C" {
391    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfdateformatteramsymbol?language=objc)
392    #[cfg(feature = "CFBase")]
393    pub static kCFDateFormatterAMSymbol: Option<&'static CFDateFormatterKey>;
394}
395
396extern "C" {
397    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfdateformatterpmsymbol?language=objc)
398    #[cfg(feature = "CFBase")]
399    pub static kCFDateFormatterPMSymbol: Option<&'static CFDateFormatterKey>;
400}
401
402extern "C" {
403    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfdateformatterlongerasymbols?language=objc)
404    #[cfg(feature = "CFBase")]
405    pub static kCFDateFormatterLongEraSymbols: Option<&'static CFDateFormatterKey>;
406}
407
408extern "C" {
409    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfdateformatterveryshortmonthsymbols?language=objc)
410    #[cfg(feature = "CFBase")]
411    pub static kCFDateFormatterVeryShortMonthSymbols: Option<&'static CFDateFormatterKey>;
412}
413
414extern "C" {
415    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfdateformatterstandalonemonthsymbols?language=objc)
416    #[cfg(feature = "CFBase")]
417    pub static kCFDateFormatterStandaloneMonthSymbols: Option<&'static CFDateFormatterKey>;
418}
419
420extern "C" {
421    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfdateformattershortstandalonemonthsymbols?language=objc)
422    #[cfg(feature = "CFBase")]
423    pub static kCFDateFormatterShortStandaloneMonthSymbols: Option<&'static CFDateFormatterKey>;
424}
425
426extern "C" {
427    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfdateformatterveryshortstandalonemonthsymbols?language=objc)
428    #[cfg(feature = "CFBase")]
429    pub static kCFDateFormatterVeryShortStandaloneMonthSymbols: Option<&'static CFDateFormatterKey>;
430}
431
432extern "C" {
433    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfdateformatterveryshortweekdaysymbols?language=objc)
434    #[cfg(feature = "CFBase")]
435    pub static kCFDateFormatterVeryShortWeekdaySymbols: Option<&'static CFDateFormatterKey>;
436}
437
438extern "C" {
439    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfdateformatterstandaloneweekdaysymbols?language=objc)
440    #[cfg(feature = "CFBase")]
441    pub static kCFDateFormatterStandaloneWeekdaySymbols: Option<&'static CFDateFormatterKey>;
442}
443
444extern "C" {
445    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfdateformattershortstandaloneweekdaysymbols?language=objc)
446    #[cfg(feature = "CFBase")]
447    pub static kCFDateFormatterShortStandaloneWeekdaySymbols: Option<&'static CFDateFormatterKey>;
448}
449
450extern "C" {
451    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfdateformatterveryshortstandaloneweekdaysymbols?language=objc)
452    #[cfg(feature = "CFBase")]
453    pub static kCFDateFormatterVeryShortStandaloneWeekdaySymbols:
454        Option<&'static CFDateFormatterKey>;
455}
456
457extern "C" {
458    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfdateformatterquartersymbols?language=objc)
459    #[cfg(feature = "CFBase")]
460    pub static kCFDateFormatterQuarterSymbols: Option<&'static CFDateFormatterKey>;
461}
462
463extern "C" {
464    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfdateformattershortquartersymbols?language=objc)
465    #[cfg(feature = "CFBase")]
466    pub static kCFDateFormatterShortQuarterSymbols: Option<&'static CFDateFormatterKey>;
467}
468
469extern "C" {
470    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfdateformatterstandalonequartersymbols?language=objc)
471    #[cfg(feature = "CFBase")]
472    pub static kCFDateFormatterStandaloneQuarterSymbols: Option<&'static CFDateFormatterKey>;
473}
474
475extern "C" {
476    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfdateformattershortstandalonequartersymbols?language=objc)
477    #[cfg(feature = "CFBase")]
478    pub static kCFDateFormatterShortStandaloneQuarterSymbols: Option<&'static CFDateFormatterKey>;
479}
480
481extern "C" {
482    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfdateformattergregorianstartdate?language=objc)
483    #[cfg(feature = "CFBase")]
484    pub static kCFDateFormatterGregorianStartDate: Option<&'static CFDateFormatterKey>;
485}
486
487extern "C" {
488    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfdateformatterdoesrelativedateformattingkey?language=objc)
489    #[cfg(feature = "CFBase")]
490    pub static kCFDateFormatterDoesRelativeDateFormattingKey: Option<&'static CFDateFormatterKey>;
491}