1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use objc2::__framework_prelude::*;

use crate::*;

// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct NSDateFormatterStyle(pub NSUInteger);
impl NSDateFormatterStyle {
    pub const NSDateFormatterNoStyle: Self = Self(0);
    pub const NSDateFormatterShortStyle: Self = Self(1);
    pub const NSDateFormatterMediumStyle: Self = Self(2);
    pub const NSDateFormatterLongStyle: Self = Self(3);
    pub const NSDateFormatterFullStyle: Self = Self(4);
}

unsafe impl Encode for NSDateFormatterStyle {
    const ENCODING: Encoding = NSUInteger::ENCODING;
}

unsafe impl RefEncode for NSDateFormatterStyle {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct NSDateFormatterBehavior(pub NSUInteger);
impl NSDateFormatterBehavior {
    #[doc(alias = "NSDateFormatterBehaviorDefault")]
    pub const Default: Self = Self(0);
    pub const NSDateFormatterBehavior10_0: Self = Self(1000);
    pub const NSDateFormatterBehavior10_4: Self = Self(1040);
}

unsafe impl Encode for NSDateFormatterBehavior {
    const ENCODING: Encoding = NSUInteger::ENCODING;
}

unsafe impl RefEncode for NSDateFormatterBehavior {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

extern_class!(
    #[derive(Debug, PartialEq, Eq, Hash)]
    #[cfg(feature = "NSFormatter")]
    pub struct NSDateFormatter;

    #[cfg(feature = "NSFormatter")]
    unsafe impl ClassType for NSDateFormatter {
        #[inherits(NSObject)]
        type Super = NSFormatter;
        type Mutability = InteriorMutable;
    }
);

#[cfg(feature = "NSFormatter")]
unsafe impl Send for NSDateFormatter {}

#[cfg(feature = "NSFormatter")]
unsafe impl Sync for NSDateFormatter {}

#[cfg(all(feature = "NSFormatter", feature = "NSObject"))]
unsafe impl NSCoding for NSDateFormatter {}

#[cfg(all(feature = "NSFormatter", feature = "NSObject"))]
unsafe impl NSCopying for NSDateFormatter {}

#[cfg(feature = "NSFormatter")]
unsafe impl NSObjectProtocol for NSDateFormatter {}

extern_methods!(
    #[cfg(feature = "NSFormatter")]
    unsafe impl NSDateFormatter {
        #[method(formattingContext)]
        pub unsafe fn formattingContext(&self) -> NSFormattingContext;

        #[method(setFormattingContext:)]
        pub unsafe fn setFormattingContext(&self, formatting_context: NSFormattingContext);

        #[cfg(all(feature = "NSError", feature = "NSRange", feature = "NSString"))]
        #[method(getObjectValue:forString:range:error:_)]
        pub unsafe fn getObjectValue_forString_range_error(
            &self,
            obj: Option<&mut Option<Retained<AnyObject>>>,
            string: &NSString,
            rangep: *mut NSRange,
        ) -> Result<(), Retained<NSError>>;

        #[cfg(all(feature = "NSDate", feature = "NSString"))]
        #[method_id(@__retain_semantics Other stringFromDate:)]
        pub unsafe fn stringFromDate(&self, date: &NSDate) -> Retained<NSString>;

        #[cfg(all(feature = "NSDate", feature = "NSString"))]
        #[method_id(@__retain_semantics Other dateFromString:)]
        pub unsafe fn dateFromString(&self, string: &NSString) -> Option<Retained<NSDate>>;

        #[cfg(all(feature = "NSDate", feature = "NSString"))]
        #[method_id(@__retain_semantics Other localizedStringFromDate:dateStyle:timeStyle:)]
        pub unsafe fn localizedStringFromDate_dateStyle_timeStyle(
            date: &NSDate,
            dstyle: NSDateFormatterStyle,
            tstyle: NSDateFormatterStyle,
        ) -> Retained<NSString>;

        #[cfg(all(feature = "NSLocale", feature = "NSString"))]
        #[method_id(@__retain_semantics Other dateFormatFromTemplate:options:locale:)]
        pub unsafe fn dateFormatFromTemplate_options_locale(
            tmplate: &NSString,
            opts: NSUInteger,
            locale: Option<&NSLocale>,
        ) -> Option<Retained<NSString>>;

        #[method(defaultFormatterBehavior)]
        pub unsafe fn defaultFormatterBehavior() -> NSDateFormatterBehavior;

        #[method(setDefaultFormatterBehavior:)]
        pub unsafe fn setDefaultFormatterBehavior(
            default_formatter_behavior: NSDateFormatterBehavior,
        );

        #[cfg(feature = "NSString")]
        #[method(setLocalizedDateFormatFromTemplate:)]
        pub unsafe fn setLocalizedDateFormatFromTemplate(&self, date_format_template: &NSString);

        #[cfg(feature = "NSString")]
        #[method_id(@__retain_semantics Other dateFormat)]
        pub unsafe fn dateFormat(&self) -> Retained<NSString>;

        #[cfg(feature = "NSString")]
        #[method(setDateFormat:)]
        pub unsafe fn setDateFormat(&self, date_format: Option<&NSString>);

        #[method(dateStyle)]
        pub unsafe fn dateStyle(&self) -> NSDateFormatterStyle;

        #[method(setDateStyle:)]
        pub unsafe fn setDateStyle(&self, date_style: NSDateFormatterStyle);

        #[method(timeStyle)]
        pub unsafe fn timeStyle(&self) -> NSDateFormatterStyle;

        #[method(setTimeStyle:)]
        pub unsafe fn setTimeStyle(&self, time_style: NSDateFormatterStyle);

        #[cfg(feature = "NSLocale")]
        #[method_id(@__retain_semantics Other locale)]
        pub unsafe fn locale(&self) -> Retained<NSLocale>;

        #[cfg(feature = "NSLocale")]
        #[method(setLocale:)]
        pub unsafe fn setLocale(&self, locale: Option<&NSLocale>);

        #[method(generatesCalendarDates)]
        pub unsafe fn generatesCalendarDates(&self) -> bool;

        #[method(setGeneratesCalendarDates:)]
        pub unsafe fn setGeneratesCalendarDates(&self, generates_calendar_dates: bool);

        #[method(formatterBehavior)]
        pub unsafe fn formatterBehavior(&self) -> NSDateFormatterBehavior;

        #[method(setFormatterBehavior:)]
        pub unsafe fn setFormatterBehavior(&self, formatter_behavior: NSDateFormatterBehavior);

        #[cfg(feature = "NSTimeZone")]
        #[method_id(@__retain_semantics Other timeZone)]
        pub unsafe fn timeZone(&self) -> Retained<NSTimeZone>;

        #[cfg(feature = "NSTimeZone")]
        #[method(setTimeZone:)]
        pub unsafe fn setTimeZone(&self, time_zone: Option<&NSTimeZone>);

        #[cfg(feature = "NSCalendar")]
        #[method_id(@__retain_semantics Other calendar)]
        pub unsafe fn calendar(&self) -> Retained<NSCalendar>;

        #[cfg(feature = "NSCalendar")]
        #[method(setCalendar:)]
        pub unsafe fn setCalendar(&self, calendar: Option<&NSCalendar>);

        #[method(isLenient)]
        pub unsafe fn isLenient(&self) -> bool;

        #[method(setLenient:)]
        pub unsafe fn setLenient(&self, lenient: bool);

        #[cfg(feature = "NSDate")]
        #[method_id(@__retain_semantics Other twoDigitStartDate)]
        pub unsafe fn twoDigitStartDate(&self) -> Option<Retained<NSDate>>;

        #[cfg(feature = "NSDate")]
        #[method(setTwoDigitStartDate:)]
        pub unsafe fn setTwoDigitStartDate(&self, two_digit_start_date: Option<&NSDate>);

        #[cfg(feature = "NSDate")]
        #[method_id(@__retain_semantics Other defaultDate)]
        pub unsafe fn defaultDate(&self) -> Option<Retained<NSDate>>;

        #[cfg(feature = "NSDate")]
        #[method(setDefaultDate:)]
        pub unsafe fn setDefaultDate(&self, default_date: Option<&NSDate>);

        #[cfg(all(feature = "NSArray", feature = "NSString"))]
        #[method_id(@__retain_semantics Other eraSymbols)]
        pub unsafe fn eraSymbols(&self) -> Retained<NSArray<NSString>>;

        #[cfg(all(feature = "NSArray", feature = "NSString"))]
        #[method(setEraSymbols:)]
        pub unsafe fn setEraSymbols(&self, era_symbols: Option<&NSArray<NSString>>);

        #[cfg(all(feature = "NSArray", feature = "NSString"))]
        #[method_id(@__retain_semantics Other monthSymbols)]
        pub unsafe fn monthSymbols(&self) -> Retained<NSArray<NSString>>;

        #[cfg(all(feature = "NSArray", feature = "NSString"))]
        #[method(setMonthSymbols:)]
        pub unsafe fn setMonthSymbols(&self, month_symbols: Option<&NSArray<NSString>>);

        #[cfg(all(feature = "NSArray", feature = "NSString"))]
        #[method_id(@__retain_semantics Other shortMonthSymbols)]
        pub unsafe fn shortMonthSymbols(&self) -> Retained<NSArray<NSString>>;

        #[cfg(all(feature = "NSArray", feature = "NSString"))]
        #[method(setShortMonthSymbols:)]
        pub unsafe fn setShortMonthSymbols(&self, short_month_symbols: Option<&NSArray<NSString>>);

        #[cfg(all(feature = "NSArray", feature = "NSString"))]
        #[method_id(@__retain_semantics Other weekdaySymbols)]
        pub unsafe fn weekdaySymbols(&self) -> Retained<NSArray<NSString>>;

        #[cfg(all(feature = "NSArray", feature = "NSString"))]
        #[method(setWeekdaySymbols:)]
        pub unsafe fn setWeekdaySymbols(&self, weekday_symbols: Option<&NSArray<NSString>>);

        #[cfg(all(feature = "NSArray", feature = "NSString"))]
        #[method_id(@__retain_semantics Other shortWeekdaySymbols)]
        pub unsafe fn shortWeekdaySymbols(&self) -> Retained<NSArray<NSString>>;

        #[cfg(all(feature = "NSArray", feature = "NSString"))]
        #[method(setShortWeekdaySymbols:)]
        pub unsafe fn setShortWeekdaySymbols(
            &self,
            short_weekday_symbols: Option<&NSArray<NSString>>,
        );

        #[cfg(feature = "NSString")]
        #[method_id(@__retain_semantics Other AMSymbol)]
        pub unsafe fn AMSymbol(&self) -> Retained<NSString>;

        #[cfg(feature = "NSString")]
        #[method(setAMSymbol:)]
        pub unsafe fn setAMSymbol(&self, am_symbol: Option<&NSString>);

        #[cfg(feature = "NSString")]
        #[method_id(@__retain_semantics Other PMSymbol)]
        pub unsafe fn PMSymbol(&self) -> Retained<NSString>;

        #[cfg(feature = "NSString")]
        #[method(setPMSymbol:)]
        pub unsafe fn setPMSymbol(&self, pm_symbol: Option<&NSString>);

        #[cfg(all(feature = "NSArray", feature = "NSString"))]
        #[method_id(@__retain_semantics Other longEraSymbols)]
        pub unsafe fn longEraSymbols(&self) -> Retained<NSArray<NSString>>;

        #[cfg(all(feature = "NSArray", feature = "NSString"))]
        #[method(setLongEraSymbols:)]
        pub unsafe fn setLongEraSymbols(&self, long_era_symbols: Option<&NSArray<NSString>>);

        #[cfg(all(feature = "NSArray", feature = "NSString"))]
        #[method_id(@__retain_semantics Other veryShortMonthSymbols)]
        pub unsafe fn veryShortMonthSymbols(&self) -> Retained<NSArray<NSString>>;

        #[cfg(all(feature = "NSArray", feature = "NSString"))]
        #[method(setVeryShortMonthSymbols:)]
        pub unsafe fn setVeryShortMonthSymbols(
            &self,
            very_short_month_symbols: Option<&NSArray<NSString>>,
        );

        #[cfg(all(feature = "NSArray", feature = "NSString"))]
        #[method_id(@__retain_semantics Other standaloneMonthSymbols)]
        pub unsafe fn standaloneMonthSymbols(&self) -> Retained<NSArray<NSString>>;

        #[cfg(all(feature = "NSArray", feature = "NSString"))]
        #[method(setStandaloneMonthSymbols:)]
        pub unsafe fn setStandaloneMonthSymbols(
            &self,
            standalone_month_symbols: Option<&NSArray<NSString>>,
        );

        #[cfg(all(feature = "NSArray", feature = "NSString"))]
        #[method_id(@__retain_semantics Other shortStandaloneMonthSymbols)]
        pub unsafe fn shortStandaloneMonthSymbols(&self) -> Retained<NSArray<NSString>>;

        #[cfg(all(feature = "NSArray", feature = "NSString"))]
        #[method(setShortStandaloneMonthSymbols:)]
        pub unsafe fn setShortStandaloneMonthSymbols(
            &self,
            short_standalone_month_symbols: Option<&NSArray<NSString>>,
        );

        #[cfg(all(feature = "NSArray", feature = "NSString"))]
        #[method_id(@__retain_semantics Other veryShortStandaloneMonthSymbols)]
        pub unsafe fn veryShortStandaloneMonthSymbols(&self) -> Retained<NSArray<NSString>>;

        #[cfg(all(feature = "NSArray", feature = "NSString"))]
        #[method(setVeryShortStandaloneMonthSymbols:)]
        pub unsafe fn setVeryShortStandaloneMonthSymbols(
            &self,
            very_short_standalone_month_symbols: Option<&NSArray<NSString>>,
        );

        #[cfg(all(feature = "NSArray", feature = "NSString"))]
        #[method_id(@__retain_semantics Other veryShortWeekdaySymbols)]
        pub unsafe fn veryShortWeekdaySymbols(&self) -> Retained<NSArray<NSString>>;

        #[cfg(all(feature = "NSArray", feature = "NSString"))]
        #[method(setVeryShortWeekdaySymbols:)]
        pub unsafe fn setVeryShortWeekdaySymbols(
            &self,
            very_short_weekday_symbols: Option<&NSArray<NSString>>,
        );

        #[cfg(all(feature = "NSArray", feature = "NSString"))]
        #[method_id(@__retain_semantics Other standaloneWeekdaySymbols)]
        pub unsafe fn standaloneWeekdaySymbols(&self) -> Retained<NSArray<NSString>>;

        #[cfg(all(feature = "NSArray", feature = "NSString"))]
        #[method(setStandaloneWeekdaySymbols:)]
        pub unsafe fn setStandaloneWeekdaySymbols(
            &self,
            standalone_weekday_symbols: Option<&NSArray<NSString>>,
        );

        #[cfg(all(feature = "NSArray", feature = "NSString"))]
        #[method_id(@__retain_semantics Other shortStandaloneWeekdaySymbols)]
        pub unsafe fn shortStandaloneWeekdaySymbols(&self) -> Retained<NSArray<NSString>>;

        #[cfg(all(feature = "NSArray", feature = "NSString"))]
        #[method(setShortStandaloneWeekdaySymbols:)]
        pub unsafe fn setShortStandaloneWeekdaySymbols(
            &self,
            short_standalone_weekday_symbols: Option<&NSArray<NSString>>,
        );

        #[cfg(all(feature = "NSArray", feature = "NSString"))]
        #[method_id(@__retain_semantics Other veryShortStandaloneWeekdaySymbols)]
        pub unsafe fn veryShortStandaloneWeekdaySymbols(&self) -> Retained<NSArray<NSString>>;

        #[cfg(all(feature = "NSArray", feature = "NSString"))]
        #[method(setVeryShortStandaloneWeekdaySymbols:)]
        pub unsafe fn setVeryShortStandaloneWeekdaySymbols(
            &self,
            very_short_standalone_weekday_symbols: Option<&NSArray<NSString>>,
        );

        #[cfg(all(feature = "NSArray", feature = "NSString"))]
        #[method_id(@__retain_semantics Other quarterSymbols)]
        pub unsafe fn quarterSymbols(&self) -> Retained<NSArray<NSString>>;

        #[cfg(all(feature = "NSArray", feature = "NSString"))]
        #[method(setQuarterSymbols:)]
        pub unsafe fn setQuarterSymbols(&self, quarter_symbols: Option<&NSArray<NSString>>);

        #[cfg(all(feature = "NSArray", feature = "NSString"))]
        #[method_id(@__retain_semantics Other shortQuarterSymbols)]
        pub unsafe fn shortQuarterSymbols(&self) -> Retained<NSArray<NSString>>;

        #[cfg(all(feature = "NSArray", feature = "NSString"))]
        #[method(setShortQuarterSymbols:)]
        pub unsafe fn setShortQuarterSymbols(
            &self,
            short_quarter_symbols: Option<&NSArray<NSString>>,
        );

        #[cfg(all(feature = "NSArray", feature = "NSString"))]
        #[method_id(@__retain_semantics Other standaloneQuarterSymbols)]
        pub unsafe fn standaloneQuarterSymbols(&self) -> Retained<NSArray<NSString>>;

        #[cfg(all(feature = "NSArray", feature = "NSString"))]
        #[method(setStandaloneQuarterSymbols:)]
        pub unsafe fn setStandaloneQuarterSymbols(
            &self,
            standalone_quarter_symbols: Option<&NSArray<NSString>>,
        );

        #[cfg(all(feature = "NSArray", feature = "NSString"))]
        #[method_id(@__retain_semantics Other shortStandaloneQuarterSymbols)]
        pub unsafe fn shortStandaloneQuarterSymbols(&self) -> Retained<NSArray<NSString>>;

        #[cfg(all(feature = "NSArray", feature = "NSString"))]
        #[method(setShortStandaloneQuarterSymbols:)]
        pub unsafe fn setShortStandaloneQuarterSymbols(
            &self,
            short_standalone_quarter_symbols: Option<&NSArray<NSString>>,
        );

        #[cfg(feature = "NSDate")]
        #[method_id(@__retain_semantics Other gregorianStartDate)]
        pub unsafe fn gregorianStartDate(&self) -> Option<Retained<NSDate>>;

        #[cfg(feature = "NSDate")]
        #[method(setGregorianStartDate:)]
        pub unsafe fn setGregorianStartDate(&self, gregorian_start_date: Option<&NSDate>);

        #[method(doesRelativeDateFormatting)]
        pub unsafe fn doesRelativeDateFormatting(&self) -> bool;

        #[method(setDoesRelativeDateFormatting:)]
        pub unsafe fn setDoesRelativeDateFormatting(&self, does_relative_date_formatting: bool);
    }
);

extern_methods!(
    /// Methods declared on superclass `NSObject`
    #[cfg(feature = "NSFormatter")]
    unsafe impl NSDateFormatter {
        #[method_id(@__retain_semantics Init init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;

        #[method_id(@__retain_semantics New new)]
        pub unsafe fn new() -> Retained<Self>;
    }
);

extern_methods!(
    /// NSDateFormatterCompatibility
    #[cfg(feature = "NSFormatter")]
    unsafe impl NSDateFormatter {
        #[cfg(feature = "NSString")]
        #[deprecated = "Create an NSDateFormatter with `init` and set the dateFormat property instead."]
        #[method_id(@__retain_semantics Init initWithDateFormat:allowNaturalLanguage:)]
        pub unsafe fn initWithDateFormat_allowNaturalLanguage(
            this: Allocated<Self>,
            format: &NSString,
            flag: bool,
        ) -> Retained<Self>;

        #[deprecated = "There is no replacement"]
        #[method(allowsNaturalLanguage)]
        pub unsafe fn allowsNaturalLanguage(&self) -> bool;
    }
);