1use 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
12pub type CFDateFormatterKey = CFString;
15
16#[doc(alias = "CFDateFormatterRef")]
18#[repr(C)]
19pub struct CFDateFormatter {
20 inner: [u8; 0],
21 _p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
22}
23
24cf_type!(
25 unsafe impl CFDateFormatter {}
26);
27#[cfg(feature = "objc2")]
28cf_objc2_type!(
29 unsafe impl RefEncode<"__CFDateFormatter"> for CFDateFormatter {}
30);
31
32impl CFDateFormatter {
33 #[doc(alias = "CFDateFormatterCreateDateFormatFromTemplate")]
39 #[cfg(feature = "CFLocale")]
40 #[inline]
41 pub unsafe fn new_date_format_from_template(
42 allocator: Option<&CFAllocator>,
43 tmplate: Option<&CFString>,
44 options: CFOptionFlags,
45 locale: Option<&CFLocale>,
46 ) -> Option<CFRetained<CFString>> {
47 extern "C-unwind" {
48 fn CFDateFormatterCreateDateFormatFromTemplate(
49 allocator: Option<&CFAllocator>,
50 tmplate: Option<&CFString>,
51 options: CFOptionFlags,
52 locale: Option<&CFLocale>,
53 ) -> Option<NonNull<CFString>>;
54 }
55 let ret = unsafe {
56 CFDateFormatterCreateDateFormatFromTemplate(allocator, tmplate, options, locale)
57 };
58 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
59 }
60}
61
62unsafe impl ConcreteType for CFDateFormatter {
63 #[doc(alias = "CFDateFormatterGetTypeID")]
64 #[inline]
65 fn type_id() -> CFTypeID {
66 extern "C-unwind" {
67 fn CFDateFormatterGetTypeID() -> CFTypeID;
68 }
69 unsafe { CFDateFormatterGetTypeID() }
70 }
71}
72
73#[repr(transparent)]
76#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
77pub struct CFDateFormatterStyle(pub CFIndex);
78impl CFDateFormatterStyle {
79 #[doc(alias = "kCFDateFormatterNoStyle")]
80 pub const NoStyle: Self = Self(0);
81 #[doc(alias = "kCFDateFormatterShortStyle")]
82 pub const ShortStyle: Self = Self(1);
83 #[doc(alias = "kCFDateFormatterMediumStyle")]
84 pub const MediumStyle: Self = Self(2);
85 #[doc(alias = "kCFDateFormatterLongStyle")]
86 pub const LongStyle: Self = Self(3);
87 #[doc(alias = "kCFDateFormatterFullStyle")]
88 pub const FullStyle: Self = Self(4);
89}
90
91#[cfg(feature = "objc2")]
92unsafe impl Encode for CFDateFormatterStyle {
93 const ENCODING: Encoding = CFIndex::ENCODING;
94}
95
96#[cfg(feature = "objc2")]
97unsafe impl RefEncode for CFDateFormatterStyle {
98 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
99}
100
101#[repr(transparent)]
104#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
105pub struct CFISO8601DateFormatOptions(pub CFOptionFlags);
106bitflags::bitflags! {
107 impl CFISO8601DateFormatOptions: CFOptionFlags {
108 #[doc(alias = "kCFISO8601DateFormatWithYear")]
109 const WithYear = 1<<0;
110 #[doc(alias = "kCFISO8601DateFormatWithMonth")]
111 const WithMonth = 1<<1;
112 #[doc(alias = "kCFISO8601DateFormatWithWeekOfYear")]
113 const WithWeekOfYear = 1<<2;
114 #[doc(alias = "kCFISO8601DateFormatWithDay")]
115 const WithDay = 1<<4;
116 #[doc(alias = "kCFISO8601DateFormatWithTime")]
117 const WithTime = 1<<5;
118 #[doc(alias = "kCFISO8601DateFormatWithTimeZone")]
119 const WithTimeZone = 1<<6;
120 #[doc(alias = "kCFISO8601DateFormatWithSpaceBetweenDateAndTime")]
121 const WithSpaceBetweenDateAndTime = 1<<7;
122 #[doc(alias = "kCFISO8601DateFormatWithDashSeparatorInDate")]
123 const WithDashSeparatorInDate = 1<<8;
124 #[doc(alias = "kCFISO8601DateFormatWithColonSeparatorInTime")]
125 const WithColonSeparatorInTime = 1<<9;
126 #[doc(alias = "kCFISO8601DateFormatWithColonSeparatorInTimeZone")]
127 const WithColonSeparatorInTimeZone = 1<<10;
128 #[doc(alias = "kCFISO8601DateFormatWithFractionalSeconds")]
129 const WithFractionalSeconds = 1<<11;
130 #[doc(alias = "kCFISO8601DateFormatWithFullDate")]
131 const WithFullDate = CFISO8601DateFormatOptions::WithYear.0|CFISO8601DateFormatOptions::WithMonth.0|CFISO8601DateFormatOptions::WithDay.0|CFISO8601DateFormatOptions::WithDashSeparatorInDate.0;
132 #[doc(alias = "kCFISO8601DateFormatWithFullTime")]
133 const WithFullTime = CFISO8601DateFormatOptions::WithTime.0|CFISO8601DateFormatOptions::WithColonSeparatorInTime.0|CFISO8601DateFormatOptions::WithTimeZone.0|CFISO8601DateFormatOptions::WithColonSeparatorInTimeZone.0;
134 #[doc(alias = "kCFISO8601DateFormatWithInternetDateTime")]
135 const WithInternetDateTime = CFISO8601DateFormatOptions::WithFullDate.0|CFISO8601DateFormatOptions::WithFullTime.0;
136 }
137}
138
139#[cfg(feature = "objc2")]
140unsafe impl Encode for CFISO8601DateFormatOptions {
141 const ENCODING: Encoding = CFOptionFlags::ENCODING;
142}
143
144#[cfg(feature = "objc2")]
145unsafe impl RefEncode for CFISO8601DateFormatOptions {
146 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
147}
148
149impl CFDateFormatter {
150 #[doc(alias = "CFDateFormatterCreateISO8601Formatter")]
154 #[inline]
155 pub unsafe fn new_iso_8601_formatter(
156 allocator: Option<&CFAllocator>,
157 format_options: CFISO8601DateFormatOptions,
158 ) -> Option<CFRetained<CFDateFormatter>> {
159 extern "C-unwind" {
160 fn CFDateFormatterCreateISO8601Formatter(
161 allocator: Option<&CFAllocator>,
162 format_options: CFISO8601DateFormatOptions,
163 ) -> Option<NonNull<CFDateFormatter>>;
164 }
165 let ret = unsafe { CFDateFormatterCreateISO8601Formatter(allocator, format_options) };
166 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
167 }
168
169 #[doc(alias = "CFDateFormatterCreate")]
174 #[cfg(feature = "CFLocale")]
175 #[inline]
176 pub unsafe fn new(
177 allocator: Option<&CFAllocator>,
178 locale: Option<&CFLocale>,
179 date_style: CFDateFormatterStyle,
180 time_style: CFDateFormatterStyle,
181 ) -> Option<CFRetained<CFDateFormatter>> {
182 extern "C-unwind" {
183 fn CFDateFormatterCreate(
184 allocator: Option<&CFAllocator>,
185 locale: Option<&CFLocale>,
186 date_style: CFDateFormatterStyle,
187 time_style: CFDateFormatterStyle,
188 ) -> Option<NonNull<CFDateFormatter>>;
189 }
190 let ret = unsafe { CFDateFormatterCreate(allocator, locale, date_style, time_style) };
191 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
192 }
193
194 #[doc(alias = "CFDateFormatterGetLocale")]
195 #[cfg(feature = "CFLocale")]
196 #[inline]
197 pub fn locale(&self) -> Option<CFRetained<CFLocale>> {
198 extern "C-unwind" {
199 fn CFDateFormatterGetLocale(formatter: &CFDateFormatter) -> Option<NonNull<CFLocale>>;
200 }
201 let ret = unsafe { CFDateFormatterGetLocale(self) };
202 ret.map(|ret| unsafe { CFRetained::retain(ret) })
203 }
204
205 #[doc(alias = "CFDateFormatterGetDateStyle")]
206 #[inline]
207 pub fn date_style(&self) -> CFDateFormatterStyle {
208 extern "C-unwind" {
209 fn CFDateFormatterGetDateStyle(formatter: &CFDateFormatter) -> CFDateFormatterStyle;
210 }
211 unsafe { CFDateFormatterGetDateStyle(self) }
212 }
213
214 #[doc(alias = "CFDateFormatterGetTimeStyle")]
215 #[inline]
216 pub fn time_style(&self) -> CFDateFormatterStyle {
217 extern "C-unwind" {
218 fn CFDateFormatterGetTimeStyle(formatter: &CFDateFormatter) -> CFDateFormatterStyle;
219 }
220 unsafe { CFDateFormatterGetTimeStyle(self) }
221 }
222
223 #[doc(alias = "CFDateFormatterGetFormat")]
224 #[inline]
225 pub fn format(&self) -> Option<CFRetained<CFString>> {
226 extern "C-unwind" {
227 fn CFDateFormatterGetFormat(formatter: &CFDateFormatter) -> Option<NonNull<CFString>>;
228 }
229 let ret = unsafe { CFDateFormatterGetFormat(self) };
230 ret.map(|ret| unsafe { CFRetained::retain(ret) })
231 }
232
233 #[doc(alias = "CFDateFormatterSetFormat")]
237 #[inline]
238 pub unsafe fn set_format(&self, format_string: Option<&CFString>) {
239 extern "C-unwind" {
240 fn CFDateFormatterSetFormat(
241 formatter: &CFDateFormatter,
242 format_string: Option<&CFString>,
243 );
244 }
245 unsafe { CFDateFormatterSetFormat(self, format_string) }
246 }
247
248 #[doc(alias = "CFDateFormatterCreateStringWithDate")]
254 #[cfg(feature = "CFDate")]
255 #[inline]
256 pub unsafe fn new_string_with_date(
257 allocator: Option<&CFAllocator>,
258 formatter: Option<&CFDateFormatter>,
259 date: Option<&CFDate>,
260 ) -> Option<CFRetained<CFString>> {
261 extern "C-unwind" {
262 fn CFDateFormatterCreateStringWithDate(
263 allocator: Option<&CFAllocator>,
264 formatter: Option<&CFDateFormatter>,
265 date: Option<&CFDate>,
266 ) -> Option<NonNull<CFString>>;
267 }
268 let ret = unsafe { CFDateFormatterCreateStringWithDate(allocator, formatter, date) };
269 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
270 }
271
272 #[doc(alias = "CFDateFormatterCreateStringWithAbsoluteTime")]
277 #[cfg(feature = "CFDate")]
278 #[inline]
279 pub unsafe fn new_string_with_absolute_time(
280 allocator: Option<&CFAllocator>,
281 formatter: Option<&CFDateFormatter>,
282 at: CFAbsoluteTime,
283 ) -> Option<CFRetained<CFString>> {
284 extern "C-unwind" {
285 fn CFDateFormatterCreateStringWithAbsoluteTime(
286 allocator: Option<&CFAllocator>,
287 formatter: Option<&CFDateFormatter>,
288 at: CFAbsoluteTime,
289 ) -> Option<NonNull<CFString>>;
290 }
291 let ret = unsafe { CFDateFormatterCreateStringWithAbsoluteTime(allocator, formatter, at) };
292 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
293 }
294
295 #[doc(alias = "CFDateFormatterCreateDateFromString")]
302 #[cfg(feature = "CFDate")]
303 #[inline]
304 pub unsafe fn new_date_from_string(
305 allocator: Option<&CFAllocator>,
306 formatter: Option<&CFDateFormatter>,
307 string: Option<&CFString>,
308 rangep: *mut CFRange,
309 ) -> Option<CFRetained<CFDate>> {
310 extern "C-unwind" {
311 fn CFDateFormatterCreateDateFromString(
312 allocator: Option<&CFAllocator>,
313 formatter: Option<&CFDateFormatter>,
314 string: Option<&CFString>,
315 rangep: *mut CFRange,
316 ) -> Option<NonNull<CFDate>>;
317 }
318 let ret =
319 unsafe { CFDateFormatterCreateDateFromString(allocator, formatter, string, rangep) };
320 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
321 }
322
323 #[doc(alias = "CFDateFormatterGetAbsoluteTimeFromString")]
329 #[cfg(feature = "CFDate")]
330 #[inline]
331 pub unsafe fn absolute_time_from_string(
332 &self,
333 string: Option<&CFString>,
334 rangep: *mut CFRange,
335 atp: *mut CFAbsoluteTime,
336 ) -> bool {
337 extern "C-unwind" {
338 fn CFDateFormatterGetAbsoluteTimeFromString(
339 formatter: &CFDateFormatter,
340 string: Option<&CFString>,
341 rangep: *mut CFRange,
342 atp: *mut CFAbsoluteTime,
343 ) -> Boolean;
344 }
345 let ret = unsafe { CFDateFormatterGetAbsoluteTimeFromString(self, string, rangep, atp) };
346 ret != 0
347 }
348
349 #[doc(alias = "CFDateFormatterSetProperty")]
355 #[inline]
356 pub unsafe fn set_property(&self, key: Option<&CFString>, value: Option<&CFType>) {
357 extern "C-unwind" {
358 fn CFDateFormatterSetProperty(
359 formatter: &CFDateFormatter,
360 key: Option<&CFString>,
361 value: Option<&CFType>,
362 );
363 }
364 unsafe { CFDateFormatterSetProperty(self, key, value) }
365 }
366
367 #[doc(alias = "CFDateFormatterCopyProperty")]
371 #[inline]
372 pub unsafe fn property(&self, key: Option<&CFDateFormatterKey>) -> Option<CFRetained<CFType>> {
373 extern "C-unwind" {
374 fn CFDateFormatterCopyProperty(
375 formatter: &CFDateFormatter,
376 key: Option<&CFDateFormatterKey>,
377 ) -> Option<NonNull<CFType>>;
378 }
379 let ret = unsafe { CFDateFormatterCopyProperty(self, key) };
380 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
381 }
382}
383
384extern "C" {
385 pub static kCFDateFormatterIsLenient: Option<&'static CFDateFormatterKey>;
387}
388
389extern "C" {
390 pub static kCFDateFormatterTimeZone: Option<&'static CFDateFormatterKey>;
392}
393
394extern "C" {
395 pub static kCFDateFormatterCalendarName: Option<&'static CFDateFormatterKey>;
397}
398
399extern "C" {
400 pub static kCFDateFormatterDefaultFormat: Option<&'static CFDateFormatterKey>;
402}
403
404extern "C" {
405 pub static kCFDateFormatterTwoDigitStartDate: Option<&'static CFDateFormatterKey>;
407}
408
409extern "C" {
410 pub static kCFDateFormatterDefaultDate: Option<&'static CFDateFormatterKey>;
412}
413
414extern "C" {
415 pub static kCFDateFormatterCalendar: Option<&'static CFDateFormatterKey>;
417}
418
419extern "C" {
420 pub static kCFDateFormatterEraSymbols: Option<&'static CFDateFormatterKey>;
422}
423
424extern "C" {
425 pub static kCFDateFormatterMonthSymbols: Option<&'static CFDateFormatterKey>;
427}
428
429extern "C" {
430 pub static kCFDateFormatterShortMonthSymbols: Option<&'static CFDateFormatterKey>;
432}
433
434extern "C" {
435 pub static kCFDateFormatterWeekdaySymbols: Option<&'static CFDateFormatterKey>;
437}
438
439extern "C" {
440 pub static kCFDateFormatterShortWeekdaySymbols: Option<&'static CFDateFormatterKey>;
442}
443
444extern "C" {
445 pub static kCFDateFormatterAMSymbol: Option<&'static CFDateFormatterKey>;
447}
448
449extern "C" {
450 pub static kCFDateFormatterPMSymbol: Option<&'static CFDateFormatterKey>;
452}
453
454extern "C" {
455 pub static kCFDateFormatterLongEraSymbols: Option<&'static CFDateFormatterKey>;
457}
458
459extern "C" {
460 pub static kCFDateFormatterVeryShortMonthSymbols: Option<&'static CFDateFormatterKey>;
462}
463
464extern "C" {
465 pub static kCFDateFormatterStandaloneMonthSymbols: Option<&'static CFDateFormatterKey>;
467}
468
469extern "C" {
470 pub static kCFDateFormatterShortStandaloneMonthSymbols: Option<&'static CFDateFormatterKey>;
472}
473
474extern "C" {
475 pub static kCFDateFormatterVeryShortStandaloneMonthSymbols: Option<&'static CFDateFormatterKey>;
477}
478
479extern "C" {
480 pub static kCFDateFormatterVeryShortWeekdaySymbols: Option<&'static CFDateFormatterKey>;
482}
483
484extern "C" {
485 pub static kCFDateFormatterStandaloneWeekdaySymbols: Option<&'static CFDateFormatterKey>;
487}
488
489extern "C" {
490 pub static kCFDateFormatterShortStandaloneWeekdaySymbols: Option<&'static CFDateFormatterKey>;
492}
493
494extern "C" {
495 pub static kCFDateFormatterVeryShortStandaloneWeekdaySymbols:
497 Option<&'static CFDateFormatterKey>;
498}
499
500extern "C" {
501 pub static kCFDateFormatterQuarterSymbols: Option<&'static CFDateFormatterKey>;
503}
504
505extern "C" {
506 pub static kCFDateFormatterShortQuarterSymbols: Option<&'static CFDateFormatterKey>;
508}
509
510extern "C" {
511 pub static kCFDateFormatterStandaloneQuarterSymbols: Option<&'static CFDateFormatterKey>;
513}
514
515extern "C" {
516 pub static kCFDateFormatterShortStandaloneQuarterSymbols: Option<&'static CFDateFormatterKey>;
518}
519
520extern "C" {
521 pub static kCFDateFormatterGregorianStartDate: Option<&'static CFDateFormatterKey>;
523}
524
525extern "C" {
526 pub static kCFDateFormatterDoesRelativeDateFormattingKey: Option<&'static CFDateFormatterKey>;
528}
529
530#[cfg(feature = "CFLocale")]
531#[deprecated = "renamed to `CFDateFormatter::new_date_format_from_template`"]
532#[inline]
533pub unsafe extern "C-unwind" fn CFDateFormatterCreateDateFormatFromTemplate(
534 allocator: Option<&CFAllocator>,
535 tmplate: Option<&CFString>,
536 options: CFOptionFlags,
537 locale: Option<&CFLocale>,
538) -> Option<CFRetained<CFString>> {
539 extern "C-unwind" {
540 fn CFDateFormatterCreateDateFormatFromTemplate(
541 allocator: Option<&CFAllocator>,
542 tmplate: Option<&CFString>,
543 options: CFOptionFlags,
544 locale: Option<&CFLocale>,
545 ) -> Option<NonNull<CFString>>;
546 }
547 let ret =
548 unsafe { CFDateFormatterCreateDateFormatFromTemplate(allocator, tmplate, options, locale) };
549 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
550}
551
552#[deprecated = "renamed to `CFDateFormatter::new_iso_8601_formatter`"]
553#[inline]
554pub unsafe extern "C-unwind" fn CFDateFormatterCreateISO8601Formatter(
555 allocator: Option<&CFAllocator>,
556 format_options: CFISO8601DateFormatOptions,
557) -> Option<CFRetained<CFDateFormatter>> {
558 extern "C-unwind" {
559 fn CFDateFormatterCreateISO8601Formatter(
560 allocator: Option<&CFAllocator>,
561 format_options: CFISO8601DateFormatOptions,
562 ) -> Option<NonNull<CFDateFormatter>>;
563 }
564 let ret = unsafe { CFDateFormatterCreateISO8601Formatter(allocator, format_options) };
565 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
566}
567
568#[cfg(feature = "CFLocale")]
569#[deprecated = "renamed to `CFDateFormatter::new`"]
570#[inline]
571pub unsafe extern "C-unwind" fn CFDateFormatterCreate(
572 allocator: Option<&CFAllocator>,
573 locale: Option<&CFLocale>,
574 date_style: CFDateFormatterStyle,
575 time_style: CFDateFormatterStyle,
576) -> Option<CFRetained<CFDateFormatter>> {
577 extern "C-unwind" {
578 fn CFDateFormatterCreate(
579 allocator: Option<&CFAllocator>,
580 locale: Option<&CFLocale>,
581 date_style: CFDateFormatterStyle,
582 time_style: CFDateFormatterStyle,
583 ) -> Option<NonNull<CFDateFormatter>>;
584 }
585 let ret = unsafe { CFDateFormatterCreate(allocator, locale, date_style, time_style) };
586 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
587}
588
589#[cfg(feature = "CFLocale")]
590#[deprecated = "renamed to `CFDateFormatter::locale`"]
591#[inline]
592pub extern "C-unwind" fn CFDateFormatterGetLocale(
593 formatter: &CFDateFormatter,
594) -> Option<CFRetained<CFLocale>> {
595 extern "C-unwind" {
596 fn CFDateFormatterGetLocale(formatter: &CFDateFormatter) -> Option<NonNull<CFLocale>>;
597 }
598 let ret = unsafe { CFDateFormatterGetLocale(formatter) };
599 ret.map(|ret| unsafe { CFRetained::retain(ret) })
600}
601
602#[deprecated = "renamed to `CFDateFormatter::date_style`"]
603#[inline]
604pub extern "C-unwind" fn CFDateFormatterGetDateStyle(
605 formatter: &CFDateFormatter,
606) -> CFDateFormatterStyle {
607 extern "C-unwind" {
608 fn CFDateFormatterGetDateStyle(formatter: &CFDateFormatter) -> CFDateFormatterStyle;
609 }
610 unsafe { CFDateFormatterGetDateStyle(formatter) }
611}
612
613#[deprecated = "renamed to `CFDateFormatter::time_style`"]
614#[inline]
615pub extern "C-unwind" fn CFDateFormatterGetTimeStyle(
616 formatter: &CFDateFormatter,
617) -> CFDateFormatterStyle {
618 extern "C-unwind" {
619 fn CFDateFormatterGetTimeStyle(formatter: &CFDateFormatter) -> CFDateFormatterStyle;
620 }
621 unsafe { CFDateFormatterGetTimeStyle(formatter) }
622}
623
624#[deprecated = "renamed to `CFDateFormatter::format`"]
625#[inline]
626pub extern "C-unwind" fn CFDateFormatterGetFormat(
627 formatter: &CFDateFormatter,
628) -> Option<CFRetained<CFString>> {
629 extern "C-unwind" {
630 fn CFDateFormatterGetFormat(formatter: &CFDateFormatter) -> Option<NonNull<CFString>>;
631 }
632 let ret = unsafe { CFDateFormatterGetFormat(formatter) };
633 ret.map(|ret| unsafe { CFRetained::retain(ret) })
634}
635
636extern "C-unwind" {
637 #[deprecated = "renamed to `CFDateFormatter::set_format`"]
638 pub fn CFDateFormatterSetFormat(formatter: &CFDateFormatter, format_string: Option<&CFString>);
639}
640
641#[cfg(feature = "CFDate")]
642#[deprecated = "renamed to `CFDateFormatter::new_string_with_date`"]
643#[inline]
644pub unsafe extern "C-unwind" fn CFDateFormatterCreateStringWithDate(
645 allocator: Option<&CFAllocator>,
646 formatter: Option<&CFDateFormatter>,
647 date: Option<&CFDate>,
648) -> Option<CFRetained<CFString>> {
649 extern "C-unwind" {
650 fn CFDateFormatterCreateStringWithDate(
651 allocator: Option<&CFAllocator>,
652 formatter: Option<&CFDateFormatter>,
653 date: Option<&CFDate>,
654 ) -> Option<NonNull<CFString>>;
655 }
656 let ret = unsafe { CFDateFormatterCreateStringWithDate(allocator, formatter, date) };
657 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
658}
659
660#[cfg(feature = "CFDate")]
661#[deprecated = "renamed to `CFDateFormatter::new_string_with_absolute_time`"]
662#[inline]
663pub unsafe extern "C-unwind" fn CFDateFormatterCreateStringWithAbsoluteTime(
664 allocator: Option<&CFAllocator>,
665 formatter: Option<&CFDateFormatter>,
666 at: CFAbsoluteTime,
667) -> Option<CFRetained<CFString>> {
668 extern "C-unwind" {
669 fn CFDateFormatterCreateStringWithAbsoluteTime(
670 allocator: Option<&CFAllocator>,
671 formatter: Option<&CFDateFormatter>,
672 at: CFAbsoluteTime,
673 ) -> Option<NonNull<CFString>>;
674 }
675 let ret = unsafe { CFDateFormatterCreateStringWithAbsoluteTime(allocator, formatter, at) };
676 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
677}
678
679#[cfg(feature = "CFDate")]
680#[deprecated = "renamed to `CFDateFormatter::new_date_from_string`"]
681#[inline]
682pub unsafe extern "C-unwind" fn CFDateFormatterCreateDateFromString(
683 allocator: Option<&CFAllocator>,
684 formatter: Option<&CFDateFormatter>,
685 string: Option<&CFString>,
686 rangep: *mut CFRange,
687) -> Option<CFRetained<CFDate>> {
688 extern "C-unwind" {
689 fn CFDateFormatterCreateDateFromString(
690 allocator: Option<&CFAllocator>,
691 formatter: Option<&CFDateFormatter>,
692 string: Option<&CFString>,
693 rangep: *mut CFRange,
694 ) -> Option<NonNull<CFDate>>;
695 }
696 let ret = unsafe { CFDateFormatterCreateDateFromString(allocator, formatter, string, rangep) };
697 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
698}
699
700#[cfg(feature = "CFDate")]
701#[deprecated = "renamed to `CFDateFormatter::absolute_time_from_string`"]
702#[inline]
703pub unsafe extern "C-unwind" fn CFDateFormatterGetAbsoluteTimeFromString(
704 formatter: &CFDateFormatter,
705 string: Option<&CFString>,
706 rangep: *mut CFRange,
707 atp: *mut CFAbsoluteTime,
708) -> bool {
709 extern "C-unwind" {
710 fn CFDateFormatterGetAbsoluteTimeFromString(
711 formatter: &CFDateFormatter,
712 string: Option<&CFString>,
713 rangep: *mut CFRange,
714 atp: *mut CFAbsoluteTime,
715 ) -> Boolean;
716 }
717 let ret = unsafe { CFDateFormatterGetAbsoluteTimeFromString(formatter, string, rangep, atp) };
718 ret != 0
719}
720
721extern "C-unwind" {
722 #[deprecated = "renamed to `CFDateFormatter::set_property`"]
723 pub fn CFDateFormatterSetProperty(
724 formatter: &CFDateFormatter,
725 key: Option<&CFString>,
726 value: Option<&CFType>,
727 );
728}
729
730#[deprecated = "renamed to `CFDateFormatter::property`"]
731#[inline]
732pub unsafe extern "C-unwind" fn CFDateFormatterCopyProperty(
733 formatter: &CFDateFormatter,
734 key: Option<&CFDateFormatterKey>,
735) -> Option<CFRetained<CFType>> {
736 extern "C-unwind" {
737 fn CFDateFormatterCopyProperty(
738 formatter: &CFDateFormatter,
739 key: Option<&CFDateFormatterKey>,
740 ) -> Option<NonNull<CFType>>;
741 }
742 let ret = unsafe { CFDateFormatterCopyProperty(formatter, key) };
743 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
744}