icrate/generated/Foundation/
NSDateComponentsFormatter.rs1use crate::common::*;
4use crate::Foundation::*;
5
6ns_enum!(
7 #[underlying(NSInteger)]
8 pub enum NSDateComponentsFormatterUnitsStyle {
9 NSDateComponentsFormatterUnitsStylePositional = 0,
10 NSDateComponentsFormatterUnitsStyleAbbreviated = 1,
11 NSDateComponentsFormatterUnitsStyleShort = 2,
12 NSDateComponentsFormatterUnitsStyleFull = 3,
13 NSDateComponentsFormatterUnitsStyleSpellOut = 4,
14 NSDateComponentsFormatterUnitsStyleBrief = 5,
15 }
16);
17
18ns_options!(
19 #[underlying(NSUInteger)]
20 pub enum NSDateComponentsFormatterZeroFormattingBehavior {
21 NSDateComponentsFormatterZeroFormattingBehaviorNone = 0,
22 NSDateComponentsFormatterZeroFormattingBehaviorDefault = 1 << 0,
23 NSDateComponentsFormatterZeroFormattingBehaviorDropLeading = 1 << 1,
24 NSDateComponentsFormatterZeroFormattingBehaviorDropMiddle = 1 << 2,
25 NSDateComponentsFormatterZeroFormattingBehaviorDropTrailing = 1 << 3,
26 NSDateComponentsFormatterZeroFormattingBehaviorDropAll =
27 NSDateComponentsFormatterZeroFormattingBehaviorDropLeading
28 | NSDateComponentsFormatterZeroFormattingBehaviorDropMiddle
29 | NSDateComponentsFormatterZeroFormattingBehaviorDropTrailing,
30 NSDateComponentsFormatterZeroFormattingBehaviorPad = 1 << 16,
31 }
32);
33
34extern_class!(
35 #[derive(Debug, PartialEq, Eq, Hash)]
36 #[cfg(feature = "Foundation_NSDateComponentsFormatter")]
37 pub struct NSDateComponentsFormatter;
38
39 #[cfg(feature = "Foundation_NSDateComponentsFormatter")]
40 unsafe impl ClassType for NSDateComponentsFormatter {
41 #[inherits(NSObject)]
42 type Super = NSFormatter;
43 type Mutability = InteriorMutable;
44 }
45);
46
47#[cfg(feature = "Foundation_NSDateComponentsFormatter")]
48unsafe impl Send for NSDateComponentsFormatter {}
49
50#[cfg(feature = "Foundation_NSDateComponentsFormatter")]
51unsafe impl Sync for NSDateComponentsFormatter {}
52
53#[cfg(feature = "Foundation_NSDateComponentsFormatter")]
54unsafe impl NSCoding for NSDateComponentsFormatter {}
55
56#[cfg(feature = "Foundation_NSDateComponentsFormatter")]
57unsafe impl NSCopying for NSDateComponentsFormatter {}
58
59#[cfg(feature = "Foundation_NSDateComponentsFormatter")]
60unsafe impl NSObjectProtocol for NSDateComponentsFormatter {}
61
62extern_methods!(
63 #[cfg(feature = "Foundation_NSDateComponentsFormatter")]
64 unsafe impl NSDateComponentsFormatter {
65 #[cfg(feature = "Foundation_NSString")]
66 #[method_id(@__retain_semantics Other stringForObjectValue:)]
67 pub unsafe fn stringForObjectValue(&self, obj: Option<&AnyObject>) -> Option<Id<NSString>>;
68
69 #[cfg(all(
70 feature = "Foundation_NSDateComponents",
71 feature = "Foundation_NSString"
72 ))]
73 #[method_id(@__retain_semantics Other stringFromDateComponents:)]
74 pub unsafe fn stringFromDateComponents(
75 &self,
76 components: &NSDateComponents,
77 ) -> Option<Id<NSString>>;
78
79 #[cfg(all(feature = "Foundation_NSDate", feature = "Foundation_NSString"))]
80 #[method_id(@__retain_semantics Other stringFromDate:toDate:)]
81 pub unsafe fn stringFromDate_toDate(
82 &self,
83 start_date: &NSDate,
84 end_date: &NSDate,
85 ) -> Option<Id<NSString>>;
86
87 #[cfg(feature = "Foundation_NSString")]
88 #[method_id(@__retain_semantics Other stringFromTimeInterval:)]
89 pub unsafe fn stringFromTimeInterval(&self, ti: NSTimeInterval) -> Option<Id<NSString>>;
90
91 #[cfg(all(
92 feature = "Foundation_NSDateComponents",
93 feature = "Foundation_NSString"
94 ))]
95 #[method_id(@__retain_semantics Other localizedStringFromDateComponents:unitsStyle:)]
96 pub unsafe fn localizedStringFromDateComponents_unitsStyle(
97 components: &NSDateComponents,
98 units_style: NSDateComponentsFormatterUnitsStyle,
99 ) -> Option<Id<NSString>>;
100
101 #[method(unitsStyle)]
102 pub unsafe fn unitsStyle(&self) -> NSDateComponentsFormatterUnitsStyle;
103
104 #[method(setUnitsStyle:)]
105 pub unsafe fn setUnitsStyle(&self, units_style: NSDateComponentsFormatterUnitsStyle);
106
107 #[method(allowedUnits)]
108 pub unsafe fn allowedUnits(&self) -> NSCalendarUnit;
109
110 #[method(setAllowedUnits:)]
111 pub unsafe fn setAllowedUnits(&self, allowed_units: NSCalendarUnit);
112
113 #[method(zeroFormattingBehavior)]
114 pub unsafe fn zeroFormattingBehavior(
115 &self,
116 ) -> NSDateComponentsFormatterZeroFormattingBehavior;
117
118 #[method(setZeroFormattingBehavior:)]
119 pub unsafe fn setZeroFormattingBehavior(
120 &self,
121 zero_formatting_behavior: NSDateComponentsFormatterZeroFormattingBehavior,
122 );
123
124 #[cfg(feature = "Foundation_NSCalendar")]
125 #[method_id(@__retain_semantics Other calendar)]
126 pub unsafe fn calendar(&self) -> Option<Id<NSCalendar>>;
127
128 #[cfg(feature = "Foundation_NSCalendar")]
129 #[method(setCalendar:)]
130 pub unsafe fn setCalendar(&self, calendar: Option<&NSCalendar>);
131
132 #[cfg(feature = "Foundation_NSDate")]
133 #[method_id(@__retain_semantics Other referenceDate)]
134 pub unsafe fn referenceDate(&self) -> Option<Id<NSDate>>;
135
136 #[cfg(feature = "Foundation_NSDate")]
137 #[method(setReferenceDate:)]
138 pub unsafe fn setReferenceDate(&self, reference_date: Option<&NSDate>);
139
140 #[method(allowsFractionalUnits)]
141 pub unsafe fn allowsFractionalUnits(&self) -> bool;
142
143 #[method(setAllowsFractionalUnits:)]
144 pub unsafe fn setAllowsFractionalUnits(&self, allows_fractional_units: bool);
145
146 #[method(maximumUnitCount)]
147 pub unsafe fn maximumUnitCount(&self) -> NSInteger;
148
149 #[method(setMaximumUnitCount:)]
150 pub unsafe fn setMaximumUnitCount(&self, maximum_unit_count: NSInteger);
151
152 #[method(collapsesLargestUnit)]
153 pub unsafe fn collapsesLargestUnit(&self) -> bool;
154
155 #[method(setCollapsesLargestUnit:)]
156 pub unsafe fn setCollapsesLargestUnit(&self, collapses_largest_unit: bool);
157
158 #[method(includesApproximationPhrase)]
159 pub unsafe fn includesApproximationPhrase(&self) -> bool;
160
161 #[method(setIncludesApproximationPhrase:)]
162 pub unsafe fn setIncludesApproximationPhrase(&self, includes_approximation_phrase: bool);
163
164 #[method(includesTimeRemainingPhrase)]
165 pub unsafe fn includesTimeRemainingPhrase(&self) -> bool;
166
167 #[method(setIncludesTimeRemainingPhrase:)]
168 pub unsafe fn setIncludesTimeRemainingPhrase(&self, includes_time_remaining_phrase: bool);
169
170 #[method(formattingContext)]
171 pub unsafe fn formattingContext(&self) -> NSFormattingContext;
172
173 #[method(setFormattingContext:)]
174 pub unsafe fn setFormattingContext(&self, formatting_context: NSFormattingContext);
175
176 #[cfg(feature = "Foundation_NSString")]
177 #[method(getObjectValue:forString:errorDescription:)]
178 pub unsafe fn getObjectValue_forString_errorDescription(
179 &self,
180 obj: Option<&mut Option<Id<AnyObject>>>,
181 string: &NSString,
182 error: Option<&mut Option<Id<NSString>>>,
183 ) -> bool;
184 }
185);
186
187extern_methods!(
188 #[cfg(feature = "Foundation_NSDateComponentsFormatter")]
190 unsafe impl NSDateComponentsFormatter {
191 #[method_id(@__retain_semantics Init init)]
192 pub unsafe fn init(this: Allocated<Self>) -> Id<Self>;
193
194 #[method_id(@__retain_semantics New new)]
195 pub unsafe fn new() -> Id<Self>;
196 }
197);