Debian Codegraph @

.cargo/vendor/core-foundation-sys/src/calendar.rs

raw
1 // Copyright 2023 The Servo Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution.
3 //
4 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
5 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
6 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
7 // option. This file may not be copied, modified, or distributed
8 // except according to those terms.
9
10 use std::os::raw::{c_char, c_void};
11
12 use crate::base::{Boolean, CFAllocatorRef, CFIndex, CFOptionFlags, CFRange, CFTypeID};
13 use crate::date::{CFAbsoluteTime, CFTimeInterval};
14 use crate::locale::{CFCalendarIdentifier, CFLocaleRef};
15 use crate::timezone::CFTimeZoneRef;
16
17 #[repr(C)]
18 pub struct __CFCalendar(c_void);
19 pub type CFCalendarRef = *mut __CFCalendar;
20
21 pub type CFCalendarUnit = CFOptionFlags;
22 pub const kCFCalendarUnitEra: CFCalendarUnit = 1 << 1;
23 pub const kCFCalendarUnitYear: CFCalendarUnit = 1 << 2;
24 pub const kCFCalendarUnitMonth: CFCalendarUnit = 1 << 3;
25 pub const kCFCalendarUnitDay: CFCalendarUnit = 1 << 4;
26 pub const kCFCalendarUnitHour: CFCalendarUnit = 1 << 5;
27 pub const kCFCalendarUnitMinute: CFCalendarUnit = 1 << 6;
28 pub const kCFCalendarUnitSecond: CFCalendarUnit = 1 << 7;
29 pub const kCFCalendarUnitWeek: CFCalendarUnit = 1 << 8; // deprecated since macos 10.10
30 pub const kCFCalendarUnitWeekday: CFCalendarUnit = 1 << 9;
31 pub const kCFCalendarUnitWeekdayOrdinal: CFCalendarUnit = 1 << 10;
32 pub const kCFCalendarUnitQuarter: CFCalendarUnit = 1 << 11;
33 pub const kCFCalendarUnitWeekOfMonth: CFCalendarUnit = 1 << 12;
34 pub const kCFCalendarUnitWeekOfYear: CFCalendarUnit = 1 << 13;
35 pub const kCFCalendarUnitYearForWeekOfYear: CFCalendarUnit = 1 << 14;
36
37 pub const kCFCalendarComponentsWrap: CFOptionFlags = 1 << 0;
38
39 extern "C" {
40 /*
41 * CFCalendar.h
42 */
43
44 /* Creating a Calendar */
45 pub fn CFCalendarCopyCurrent() -> CFCalendarRef;
46 pub fn CFCalendarCreateWithIdentifier(
47 allocator: CFAllocatorRef,
48 identifier: CFCalendarIdentifier,
49 ) -> CFCalendarRef;
50
51 /* Calendrical Calculations */
52 pub fn CFCalendarAddComponents(
53 identifier: CFCalendarIdentifier,
54 /* inout */ at: *mut CFAbsoluteTime,
55 options: CFOptionFlags,
56 componentDesc: *const char,
57 ...
58 ) -> Boolean;
59 pub fn CFCalendarComposeAbsoluteTime(
60 identifier: CFCalendarIdentifier,
61 /* out */ 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 /* Getting Ranges of Units */
81 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 /* Getting and Setting the Time Zone */
110 pub fn CFCalendarCopyTimeZone(identifier: CFCalendarIdentifier) -> CFTimeZoneRef;
111 pub fn CFCalendarSetTimeZone(identifier: CFCalendarIdentifier, tz: CFTimeZoneRef);
112
113 /* Getting the Identifier */
114 pub fn CFCalendarGetIdentifier(identifier: CFCalendarIdentifier) -> CFCalendarIdentifier;
115
116 /* Getting and Setting the Locale */
117 pub fn CFCalendarCopyLocale(identifier: CFCalendarIdentifier) -> CFLocaleRef;
118 pub fn CFCalendarSetLocale(identifier: CFCalendarIdentifier, locale: CFLocaleRef);
119
120 /* Getting and Setting Day Information */
121 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 /* Getting the Type ID */
127 pub fn CFCalendarGetTypeID() -> CFTypeID;
128 }