core_foundation_sys/
calendar.rs1use std::os::raw::{c_char, c_void};
11
12use crate::base::{Boolean, CFAllocatorRef, CFIndex, CFOptionFlags, CFRange, CFTypeID};
13use crate::date::{CFAbsoluteTime, CFTimeInterval};
14use crate::locale::{CFCalendarIdentifier, CFLocaleRef};
15use crate::timezone::CFTimeZoneRef;
16
17#[repr(C)]
18pub struct __CFCalendar(c_void);
19pub type CFCalendarRef = *mut __CFCalendar;
20
21pub type CFCalendarUnit = CFOptionFlags;
22pub const kCFCalendarUnitEra: CFCalendarUnit = 1 << 1;
23pub const kCFCalendarUnitYear: CFCalendarUnit = 1 << 2;
24pub const kCFCalendarUnitMonth: CFCalendarUnit = 1 << 3;
25pub const kCFCalendarUnitDay: CFCalendarUnit = 1 << 4;
26pub const kCFCalendarUnitHour: CFCalendarUnit = 1 << 5;
27pub const kCFCalendarUnitMinute: CFCalendarUnit = 1 << 6;
28pub const kCFCalendarUnitSecond: CFCalendarUnit = 1 << 7;
29pub const kCFCalendarUnitWeek: CFCalendarUnit = 1 << 8; pub const kCFCalendarUnitWeekday: CFCalendarUnit = 1 << 9;
31pub const kCFCalendarUnitWeekdayOrdinal: CFCalendarUnit = 1 << 10;
32pub const kCFCalendarUnitQuarter: CFCalendarUnit = 1 << 11;
33pub const kCFCalendarUnitWeekOfMonth: CFCalendarUnit = 1 << 12;
34pub const kCFCalendarUnitWeekOfYear: CFCalendarUnit = 1 << 13;
35pub const kCFCalendarUnitYearForWeekOfYear: CFCalendarUnit = 1 << 14;
36
37pub const kCFCalendarComponentsWrap: CFOptionFlags = 1 << 0;
38
39extern "C" {
40 pub fn CFCalendarCopyCurrent() -> CFCalendarRef;
46 pub fn CFCalendarCreateWithIdentifier(
47 allocator: CFAllocatorRef,
48 identifier: CFCalendarIdentifier,
49 ) -> CFCalendarRef;
50
51 pub fn CFCalendarAddComponents(
53 identifier: CFCalendarIdentifier,
54 at: *mut CFAbsoluteTime,
55 options: CFOptionFlags,
56 componentDesc: *const char,
57 ...
58 ) -> Boolean;
59 pub fn CFCalendarComposeAbsoluteTime(
60 identifier: CFCalendarIdentifier,
61 at: *mut CFAbsoluteTime,
62 componentDesc: *const c_char,
63 ...
64 ) -> Boolean;
65 pub fn CFCalendarDecomposeAbsoluteTime(
66 identifier: CFCalendarIdentifier,
67 at: CFAbsoluteTime,
68 componentDesc: *const c_char,
69 ...
70 ) -> Boolean;
71 pub fn CFCalendarGetComponentDifference(
72 identifier: CFCalendarIdentifier,
73 startingAT: CFAbsoluteTime,
74 resultAT: CFAbsoluteTime,
75 options: CFOptionFlags,
76 componentDesc: *const c_char,
77 ...
78 ) -> Boolean;
79
80 pub fn CFCalendarGetRangeOfUnit(
82 identifier: CFCalendarIdentifier,
83 smallerUnit: CFCalendarUnit,
84 biggerUnit: CFCalendarUnit,
85 at: CFAbsoluteTime,
86 ) -> CFRange;
87 pub fn CFCalendarGetOrdinalityOfUnit(
88 identifier: CFCalendarIdentifier,
89 smallerUnit: CFCalendarUnit,
90 biggerUnit: CFCalendarUnit,
91 at: CFAbsoluteTime,
92 ) -> CFIndex;
93 pub fn CFCalendarGetTimeRangeOfUnit(
94 identifier: CFCalendarIdentifier,
95 unit: CFCalendarUnit,
96 at: CFAbsoluteTime,
97 startp: *mut CFAbsoluteTime,
98 tip: *mut CFTimeInterval,
99 ) -> Boolean;
100 pub fn CFCalendarGetMaximumRangeOfUnit(
101 identifier: CFCalendarIdentifier,
102 unit: CFCalendarUnit,
103 ) -> CFRange;
104 pub fn CFCalendarGetMinimumRangeOfUnit(
105 identifier: CFCalendarIdentifier,
106 unit: CFCalendarUnit,
107 ) -> CFRange;
108
109 pub fn CFCalendarCopyTimeZone(identifier: CFCalendarIdentifier) -> CFTimeZoneRef;
111 pub fn CFCalendarSetTimeZone(identifier: CFCalendarIdentifier, tz: CFTimeZoneRef);
112
113 pub fn CFCalendarGetIdentifier(identifier: CFCalendarIdentifier) -> CFCalendarIdentifier;
115
116 pub fn CFCalendarCopyLocale(identifier: CFCalendarIdentifier) -> CFLocaleRef;
118 pub fn CFCalendarSetLocale(identifier: CFCalendarIdentifier, locale: CFLocaleRef);
119
120 pub fn CFCalendarGetFirstWeekday(identifier: CFCalendarIdentifier) -> CFIndex;
122 pub fn CFCalendarSetFirstWeekday(identifier: CFCalendarIdentifier, wkdy: CFIndex);
123 pub fn CFCalendarGetMinimumDaysInFirstWeek(identifier: CFCalendarIdentifier) -> CFIndex;
124 pub fn CFCalendarSetMinimumDaysInFirstWeek(identifier: CFCalendarIdentifier, mwd: CFIndex);
125
126 pub fn CFCalendarGetTypeID() -> CFTypeID;
128}