objc2_foundation/generated/
NSCalendar.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6
7use crate::*;
8
9/// [Apple's documentation](https://developer.apple.com/documentation/foundation/nscalendaridentifier?language=objc)
10// NS_TYPED_EXTENSIBLE_ENUM
11#[cfg(feature = "NSString")]
12pub type NSCalendarIdentifier = NSString;
13
14extern "C" {
15    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nscalendaridentifiergregorian?language=objc)
16    #[cfg(feature = "NSString")]
17    pub static NSCalendarIdentifierGregorian: &'static NSCalendarIdentifier;
18}
19
20extern "C" {
21    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nscalendaridentifierbuddhist?language=objc)
22    #[cfg(feature = "NSString")]
23    pub static NSCalendarIdentifierBuddhist: &'static NSCalendarIdentifier;
24}
25
26extern "C" {
27    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nscalendaridentifierchinese?language=objc)
28    #[cfg(feature = "NSString")]
29    pub static NSCalendarIdentifierChinese: &'static NSCalendarIdentifier;
30}
31
32extern "C" {
33    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nscalendaridentifiercoptic?language=objc)
34    #[cfg(feature = "NSString")]
35    pub static NSCalendarIdentifierCoptic: &'static NSCalendarIdentifier;
36}
37
38extern "C" {
39    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nscalendaridentifierethiopicametemihret?language=objc)
40    #[cfg(feature = "NSString")]
41    pub static NSCalendarIdentifierEthiopicAmeteMihret: &'static NSCalendarIdentifier;
42}
43
44extern "C" {
45    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nscalendaridentifierethiopicametealem?language=objc)
46    #[cfg(feature = "NSString")]
47    pub static NSCalendarIdentifierEthiopicAmeteAlem: &'static NSCalendarIdentifier;
48}
49
50extern "C" {
51    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nscalendaridentifierhebrew?language=objc)
52    #[cfg(feature = "NSString")]
53    pub static NSCalendarIdentifierHebrew: &'static NSCalendarIdentifier;
54}
55
56extern "C" {
57    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nscalendaridentifieriso8601?language=objc)
58    #[cfg(feature = "NSString")]
59    pub static NSCalendarIdentifierISO8601: &'static NSCalendarIdentifier;
60}
61
62extern "C" {
63    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nscalendaridentifierindian?language=objc)
64    #[cfg(feature = "NSString")]
65    pub static NSCalendarIdentifierIndian: &'static NSCalendarIdentifier;
66}
67
68extern "C" {
69    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nscalendaridentifierislamic?language=objc)
70    #[cfg(feature = "NSString")]
71    pub static NSCalendarIdentifierIslamic: &'static NSCalendarIdentifier;
72}
73
74extern "C" {
75    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nscalendaridentifierislamiccivil?language=objc)
76    #[cfg(feature = "NSString")]
77    pub static NSCalendarIdentifierIslamicCivil: &'static NSCalendarIdentifier;
78}
79
80extern "C" {
81    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nscalendaridentifierjapanese?language=objc)
82    #[cfg(feature = "NSString")]
83    pub static NSCalendarIdentifierJapanese: &'static NSCalendarIdentifier;
84}
85
86extern "C" {
87    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nscalendaridentifierpersian?language=objc)
88    #[cfg(feature = "NSString")]
89    pub static NSCalendarIdentifierPersian: &'static NSCalendarIdentifier;
90}
91
92extern "C" {
93    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nscalendaridentifierrepublicofchina?language=objc)
94    #[cfg(feature = "NSString")]
95    pub static NSCalendarIdentifierRepublicOfChina: &'static NSCalendarIdentifier;
96}
97
98extern "C" {
99    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nscalendaridentifierislamictabular?language=objc)
100    #[cfg(feature = "NSString")]
101    pub static NSCalendarIdentifierIslamicTabular: &'static NSCalendarIdentifier;
102}
103
104extern "C" {
105    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nscalendaridentifierislamicummalqura?language=objc)
106    #[cfg(feature = "NSString")]
107    pub static NSCalendarIdentifierIslamicUmmAlQura: &'static NSCalendarIdentifier;
108}
109
110/// [Apple's documentation](https://developer.apple.com/documentation/foundation/nscalendarunit?language=objc)
111// NS_OPTIONS
112#[repr(transparent)]
113#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
114pub struct NSCalendarUnit(pub NSUInteger);
115bitflags::bitflags! {
116    impl NSCalendarUnit: NSUInteger {
117        #[doc(alias = "NSCalendarUnitEra")]
118        const Era = 2;
119        #[doc(alias = "NSCalendarUnitYear")]
120        const Year = 4;
121        #[doc(alias = "NSCalendarUnitMonth")]
122        const Month = 8;
123        #[doc(alias = "NSCalendarUnitDay")]
124        const Day = 16;
125        #[doc(alias = "NSCalendarUnitHour")]
126        const Hour = 32;
127        #[doc(alias = "NSCalendarUnitMinute")]
128        const Minute = 64;
129        #[doc(alias = "NSCalendarUnitSecond")]
130        const Second = 128;
131        #[doc(alias = "NSCalendarUnitWeekday")]
132        const Weekday = 512;
133        #[doc(alias = "NSCalendarUnitWeekdayOrdinal")]
134        const WeekdayOrdinal = 1024;
135        #[doc(alias = "NSCalendarUnitQuarter")]
136        const Quarter = 2048;
137        #[doc(alias = "NSCalendarUnitWeekOfMonth")]
138        const WeekOfMonth = 4096;
139        #[doc(alias = "NSCalendarUnitWeekOfYear")]
140        const WeekOfYear = 8192;
141        #[doc(alias = "NSCalendarUnitYearForWeekOfYear")]
142        const YearForWeekOfYear = 16384;
143        #[doc(alias = "NSCalendarUnitNanosecond")]
144        const Nanosecond = 32768;
145        #[doc(alias = "NSCalendarUnitDayOfYear")]
146        const DayOfYear = 65536;
147        #[doc(alias = "NSCalendarUnitCalendar")]
148        const Calendar = 1048576;
149        #[doc(alias = "NSCalendarUnitTimeZone")]
150        const TimeZone = 2097152;
151#[deprecated]
152        const NSEraCalendarUnit = 2;
153#[deprecated]
154        const NSYearCalendarUnit = 4;
155#[deprecated]
156        const NSMonthCalendarUnit = 8;
157#[deprecated]
158        const NSDayCalendarUnit = 16;
159#[deprecated]
160        const NSHourCalendarUnit = 32;
161#[deprecated]
162        const NSMinuteCalendarUnit = 64;
163#[deprecated]
164        const NSSecondCalendarUnit = 128;
165#[deprecated = "NSCalendarUnitWeekOfMonth or NSCalendarUnitWeekOfYear, depending on which you mean"]
166        const NSWeekCalendarUnit = 256;
167#[deprecated]
168        const NSWeekdayCalendarUnit = 512;
169#[deprecated]
170        const NSWeekdayOrdinalCalendarUnit = 1024;
171#[deprecated]
172        const NSQuarterCalendarUnit = 2048;
173#[deprecated]
174        const NSWeekOfMonthCalendarUnit = 4096;
175#[deprecated]
176        const NSWeekOfYearCalendarUnit = 8192;
177#[deprecated]
178        const NSYearForWeekOfYearCalendarUnit = 16384;
179#[deprecated]
180        const NSCalendarCalendarUnit = 1048576;
181#[deprecated]
182        const NSTimeZoneCalendarUnit = 2097152;
183    }
184}
185
186unsafe impl Encode for NSCalendarUnit {
187    const ENCODING: Encoding = NSUInteger::ENCODING;
188}
189
190unsafe impl RefEncode for NSCalendarUnit {
191    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
192}
193
194/// [Apple's documentation](https://developer.apple.com/documentation/foundation/nscalendaroptions?language=objc)
195// NS_OPTIONS
196#[repr(transparent)]
197#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
198pub struct NSCalendarOptions(pub NSUInteger);
199bitflags::bitflags! {
200    impl NSCalendarOptions: NSUInteger {
201        #[doc(alias = "NSCalendarWrapComponents")]
202        const WrapComponents = 1<<0;
203        #[doc(alias = "NSCalendarMatchStrictly")]
204        const MatchStrictly = 1<<1;
205        #[doc(alias = "NSCalendarSearchBackwards")]
206        const SearchBackwards = 1<<2;
207        #[doc(alias = "NSCalendarMatchPreviousTimePreservingSmallerUnits")]
208        const MatchPreviousTimePreservingSmallerUnits = 1<<8;
209        #[doc(alias = "NSCalendarMatchNextTimePreservingSmallerUnits")]
210        const MatchNextTimePreservingSmallerUnits = 1<<9;
211        #[doc(alias = "NSCalendarMatchNextTime")]
212        const MatchNextTime = 1<<10;
213        #[doc(alias = "NSCalendarMatchFirst")]
214        const MatchFirst = 1<<12;
215        #[doc(alias = "NSCalendarMatchLast")]
216        const MatchLast = 1<<13;
217    }
218}
219
220unsafe impl Encode for NSCalendarOptions {
221    const ENCODING: Encoding = NSUInteger::ENCODING;
222}
223
224unsafe impl RefEncode for NSCalendarOptions {
225    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
226}
227
228/// [Apple's documentation](https://developer.apple.com/documentation/foundation/nswrapcalendarcomponents?language=objc)
229#[deprecated]
230pub const NSWrapCalendarComponents: NSUInteger = NSCalendarOptions::WrapComponents.0;
231
232extern_class!(
233    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nscalendar?language=objc)
234    #[unsafe(super(NSObject))]
235    #[derive(Debug, PartialEq, Eq, Hash)]
236    pub struct NSCalendar;
237);
238
239#[cfg(feature = "NSObject")]
240extern_conformance!(
241    unsafe impl NSCoding for NSCalendar {}
242);
243
244#[cfg(feature = "NSObject")]
245extern_conformance!(
246    unsafe impl NSCopying for NSCalendar {}
247);
248
249#[cfg(feature = "NSObject")]
250unsafe impl CopyingHelper for NSCalendar {
251    type Result = Self;
252}
253
254extern_conformance!(
255    unsafe impl NSObjectProtocol for NSCalendar {}
256);
257
258#[cfg(feature = "NSObject")]
259extern_conformance!(
260    unsafe impl NSSecureCoding for NSCalendar {}
261);
262
263impl NSCalendar {
264    extern_methods!(
265        #[unsafe(method(currentCalendar))]
266        #[unsafe(method_family = none)]
267        pub unsafe fn currentCalendar() -> Retained<NSCalendar>;
268
269        #[unsafe(method(autoupdatingCurrentCalendar))]
270        #[unsafe(method_family = none)]
271        pub unsafe fn autoupdatingCurrentCalendar() -> Retained<NSCalendar>;
272
273        #[cfg(feature = "NSString")]
274        #[unsafe(method(calendarWithIdentifier:))]
275        #[unsafe(method_family = none)]
276        pub unsafe fn calendarWithIdentifier(
277            calendar_identifier_constant: &NSCalendarIdentifier,
278        ) -> Option<Retained<NSCalendar>>;
279
280        #[unsafe(method(init))]
281        #[unsafe(method_family = init)]
282        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
283
284        #[cfg(feature = "NSString")]
285        #[unsafe(method(initWithCalendarIdentifier:))]
286        #[unsafe(method_family = init)]
287        pub unsafe fn initWithCalendarIdentifier(
288            this: Allocated<Self>,
289            ident: &NSCalendarIdentifier,
290        ) -> Option<Retained<Self>>;
291
292        #[cfg(feature = "NSString")]
293        #[unsafe(method(calendarIdentifier))]
294        #[unsafe(method_family = none)]
295        pub unsafe fn calendarIdentifier(&self) -> Retained<NSCalendarIdentifier>;
296
297        #[cfg(feature = "NSLocale")]
298        #[unsafe(method(locale))]
299        #[unsafe(method_family = none)]
300        pub unsafe fn locale(&self) -> Option<Retained<NSLocale>>;
301
302        #[cfg(feature = "NSLocale")]
303        /// Setter for [`locale`][Self::locale].
304        #[unsafe(method(setLocale:))]
305        #[unsafe(method_family = none)]
306        pub unsafe fn setLocale(&self, locale: Option<&NSLocale>);
307
308        #[cfg(feature = "NSTimeZone")]
309        #[unsafe(method(timeZone))]
310        #[unsafe(method_family = none)]
311        pub unsafe fn timeZone(&self) -> Retained<NSTimeZone>;
312
313        #[cfg(feature = "NSTimeZone")]
314        /// Setter for [`timeZone`][Self::timeZone].
315        #[unsafe(method(setTimeZone:))]
316        #[unsafe(method_family = none)]
317        pub unsafe fn setTimeZone(&self, time_zone: &NSTimeZone);
318
319        #[unsafe(method(firstWeekday))]
320        #[unsafe(method_family = none)]
321        pub unsafe fn firstWeekday(&self) -> NSUInteger;
322
323        /// Setter for [`firstWeekday`][Self::firstWeekday].
324        #[unsafe(method(setFirstWeekday:))]
325        #[unsafe(method_family = none)]
326        pub unsafe fn setFirstWeekday(&self, first_weekday: NSUInteger);
327
328        #[unsafe(method(minimumDaysInFirstWeek))]
329        #[unsafe(method_family = none)]
330        pub unsafe fn minimumDaysInFirstWeek(&self) -> NSUInteger;
331
332        /// Setter for [`minimumDaysInFirstWeek`][Self::minimumDaysInFirstWeek].
333        #[unsafe(method(setMinimumDaysInFirstWeek:))]
334        #[unsafe(method_family = none)]
335        pub unsafe fn setMinimumDaysInFirstWeek(&self, minimum_days_in_first_week: NSUInteger);
336
337        #[cfg(all(feature = "NSArray", feature = "NSString"))]
338        #[unsafe(method(eraSymbols))]
339        #[unsafe(method_family = none)]
340        pub unsafe fn eraSymbols(&self) -> Retained<NSArray<NSString>>;
341
342        #[cfg(all(feature = "NSArray", feature = "NSString"))]
343        #[unsafe(method(longEraSymbols))]
344        #[unsafe(method_family = none)]
345        pub unsafe fn longEraSymbols(&self) -> Retained<NSArray<NSString>>;
346
347        #[cfg(all(feature = "NSArray", feature = "NSString"))]
348        #[unsafe(method(monthSymbols))]
349        #[unsafe(method_family = none)]
350        pub unsafe fn monthSymbols(&self) -> Retained<NSArray<NSString>>;
351
352        #[cfg(all(feature = "NSArray", feature = "NSString"))]
353        #[unsafe(method(shortMonthSymbols))]
354        #[unsafe(method_family = none)]
355        pub unsafe fn shortMonthSymbols(&self) -> Retained<NSArray<NSString>>;
356
357        #[cfg(all(feature = "NSArray", feature = "NSString"))]
358        #[unsafe(method(veryShortMonthSymbols))]
359        #[unsafe(method_family = none)]
360        pub unsafe fn veryShortMonthSymbols(&self) -> Retained<NSArray<NSString>>;
361
362        #[cfg(all(feature = "NSArray", feature = "NSString"))]
363        #[unsafe(method(standaloneMonthSymbols))]
364        #[unsafe(method_family = none)]
365        pub unsafe fn standaloneMonthSymbols(&self) -> Retained<NSArray<NSString>>;
366
367        #[cfg(all(feature = "NSArray", feature = "NSString"))]
368        #[unsafe(method(shortStandaloneMonthSymbols))]
369        #[unsafe(method_family = none)]
370        pub unsafe fn shortStandaloneMonthSymbols(&self) -> Retained<NSArray<NSString>>;
371
372        #[cfg(all(feature = "NSArray", feature = "NSString"))]
373        #[unsafe(method(veryShortStandaloneMonthSymbols))]
374        #[unsafe(method_family = none)]
375        pub unsafe fn veryShortStandaloneMonthSymbols(&self) -> Retained<NSArray<NSString>>;
376
377        #[cfg(all(feature = "NSArray", feature = "NSString"))]
378        #[unsafe(method(weekdaySymbols))]
379        #[unsafe(method_family = none)]
380        pub unsafe fn weekdaySymbols(&self) -> Retained<NSArray<NSString>>;
381
382        #[cfg(all(feature = "NSArray", feature = "NSString"))]
383        #[unsafe(method(shortWeekdaySymbols))]
384        #[unsafe(method_family = none)]
385        pub unsafe fn shortWeekdaySymbols(&self) -> Retained<NSArray<NSString>>;
386
387        #[cfg(all(feature = "NSArray", feature = "NSString"))]
388        #[unsafe(method(veryShortWeekdaySymbols))]
389        #[unsafe(method_family = none)]
390        pub unsafe fn veryShortWeekdaySymbols(&self) -> Retained<NSArray<NSString>>;
391
392        #[cfg(all(feature = "NSArray", feature = "NSString"))]
393        #[unsafe(method(standaloneWeekdaySymbols))]
394        #[unsafe(method_family = none)]
395        pub unsafe fn standaloneWeekdaySymbols(&self) -> Retained<NSArray<NSString>>;
396
397        #[cfg(all(feature = "NSArray", feature = "NSString"))]
398        #[unsafe(method(shortStandaloneWeekdaySymbols))]
399        #[unsafe(method_family = none)]
400        pub unsafe fn shortStandaloneWeekdaySymbols(&self) -> Retained<NSArray<NSString>>;
401
402        #[cfg(all(feature = "NSArray", feature = "NSString"))]
403        #[unsafe(method(veryShortStandaloneWeekdaySymbols))]
404        #[unsafe(method_family = none)]
405        pub unsafe fn veryShortStandaloneWeekdaySymbols(&self) -> Retained<NSArray<NSString>>;
406
407        #[cfg(all(feature = "NSArray", feature = "NSString"))]
408        #[unsafe(method(quarterSymbols))]
409        #[unsafe(method_family = none)]
410        pub unsafe fn quarterSymbols(&self) -> Retained<NSArray<NSString>>;
411
412        #[cfg(all(feature = "NSArray", feature = "NSString"))]
413        #[unsafe(method(shortQuarterSymbols))]
414        #[unsafe(method_family = none)]
415        pub unsafe fn shortQuarterSymbols(&self) -> Retained<NSArray<NSString>>;
416
417        #[cfg(all(feature = "NSArray", feature = "NSString"))]
418        #[unsafe(method(standaloneQuarterSymbols))]
419        #[unsafe(method_family = none)]
420        pub unsafe fn standaloneQuarterSymbols(&self) -> Retained<NSArray<NSString>>;
421
422        #[cfg(all(feature = "NSArray", feature = "NSString"))]
423        #[unsafe(method(shortStandaloneQuarterSymbols))]
424        #[unsafe(method_family = none)]
425        pub unsafe fn shortStandaloneQuarterSymbols(&self) -> Retained<NSArray<NSString>>;
426
427        #[cfg(feature = "NSString")]
428        #[unsafe(method(AMSymbol))]
429        #[unsafe(method_family = none)]
430        pub unsafe fn AMSymbol(&self) -> Retained<NSString>;
431
432        #[cfg(feature = "NSString")]
433        #[unsafe(method(PMSymbol))]
434        #[unsafe(method_family = none)]
435        pub unsafe fn PMSymbol(&self) -> Retained<NSString>;
436
437        #[cfg(feature = "NSRange")]
438        #[unsafe(method(minimumRangeOfUnit:))]
439        #[unsafe(method_family = none)]
440        pub unsafe fn minimumRangeOfUnit(&self, unit: NSCalendarUnit) -> NSRange;
441
442        #[cfg(feature = "NSRange")]
443        #[unsafe(method(maximumRangeOfUnit:))]
444        #[unsafe(method_family = none)]
445        pub unsafe fn maximumRangeOfUnit(&self, unit: NSCalendarUnit) -> NSRange;
446
447        #[cfg(all(feature = "NSDate", feature = "NSRange"))]
448        #[unsafe(method(rangeOfUnit:inUnit:forDate:))]
449        #[unsafe(method_family = none)]
450        pub unsafe fn rangeOfUnit_inUnit_forDate(
451            &self,
452            smaller: NSCalendarUnit,
453            larger: NSCalendarUnit,
454            date: &NSDate,
455        ) -> NSRange;
456
457        #[cfg(feature = "NSDate")]
458        #[unsafe(method(ordinalityOfUnit:inUnit:forDate:))]
459        #[unsafe(method_family = none)]
460        pub unsafe fn ordinalityOfUnit_inUnit_forDate(
461            &self,
462            smaller: NSCalendarUnit,
463            larger: NSCalendarUnit,
464            date: &NSDate,
465        ) -> NSUInteger;
466
467        #[cfg(feature = "NSDate")]
468        #[unsafe(method(rangeOfUnit:startDate:interval:forDate:))]
469        #[unsafe(method_family = none)]
470        pub unsafe fn rangeOfUnit_startDate_interval_forDate(
471            &self,
472            unit: NSCalendarUnit,
473            datep: Option<&mut Option<Retained<NSDate>>>,
474            tip: *mut NSTimeInterval,
475            date: &NSDate,
476        ) -> bool;
477
478        #[cfg(feature = "NSDate")]
479        #[unsafe(method(dateFromComponents:))]
480        #[unsafe(method_family = none)]
481        pub unsafe fn dateFromComponents(
482            &self,
483            comps: &NSDateComponents,
484        ) -> Option<Retained<NSDate>>;
485
486        #[cfg(feature = "NSDate")]
487        #[unsafe(method(components:fromDate:))]
488        #[unsafe(method_family = none)]
489        pub unsafe fn components_fromDate(
490            &self,
491            unit_flags: NSCalendarUnit,
492            date: &NSDate,
493        ) -> Retained<NSDateComponents>;
494
495        #[cfg(feature = "NSDate")]
496        #[unsafe(method(dateByAddingComponents:toDate:options:))]
497        #[unsafe(method_family = none)]
498        pub unsafe fn dateByAddingComponents_toDate_options(
499            &self,
500            comps: &NSDateComponents,
501            date: &NSDate,
502            opts: NSCalendarOptions,
503        ) -> Option<Retained<NSDate>>;
504
505        #[cfg(feature = "NSDate")]
506        #[unsafe(method(components:fromDate:toDate:options:))]
507        #[unsafe(method_family = none)]
508        pub unsafe fn components_fromDate_toDate_options(
509            &self,
510            unit_flags: NSCalendarUnit,
511            starting_date: &NSDate,
512            result_date: &NSDate,
513            opts: NSCalendarOptions,
514        ) -> Retained<NSDateComponents>;
515
516        #[cfg(feature = "NSDate")]
517        #[unsafe(method(getEra:year:month:day:fromDate:))]
518        #[unsafe(method_family = none)]
519        pub unsafe fn getEra_year_month_day_fromDate(
520            &self,
521            era_value_pointer: *mut NSInteger,
522            year_value_pointer: *mut NSInteger,
523            month_value_pointer: *mut NSInteger,
524            day_value_pointer: *mut NSInteger,
525            date: &NSDate,
526        );
527
528        #[cfg(feature = "NSDate")]
529        #[unsafe(method(getEra:yearForWeekOfYear:weekOfYear:weekday:fromDate:))]
530        #[unsafe(method_family = none)]
531        pub unsafe fn getEra_yearForWeekOfYear_weekOfYear_weekday_fromDate(
532            &self,
533            era_value_pointer: *mut NSInteger,
534            year_value_pointer: *mut NSInteger,
535            week_value_pointer: *mut NSInteger,
536            weekday_value_pointer: *mut NSInteger,
537            date: &NSDate,
538        );
539
540        #[cfg(feature = "NSDate")]
541        #[unsafe(method(getHour:minute:second:nanosecond:fromDate:))]
542        #[unsafe(method_family = none)]
543        pub unsafe fn getHour_minute_second_nanosecond_fromDate(
544            &self,
545            hour_value_pointer: *mut NSInteger,
546            minute_value_pointer: *mut NSInteger,
547            second_value_pointer: *mut NSInteger,
548            nanosecond_value_pointer: *mut NSInteger,
549            date: &NSDate,
550        );
551
552        #[cfg(feature = "NSDate")]
553        #[unsafe(method(component:fromDate:))]
554        #[unsafe(method_family = none)]
555        pub unsafe fn component_fromDate(&self, unit: NSCalendarUnit, date: &NSDate) -> NSInteger;
556
557        #[cfg(feature = "NSDate")]
558        #[unsafe(method(dateWithEra:year:month:day:hour:minute:second:nanosecond:))]
559        #[unsafe(method_family = none)]
560        pub unsafe fn dateWithEra_year_month_day_hour_minute_second_nanosecond(
561            &self,
562            era_value: NSInteger,
563            year_value: NSInteger,
564            month_value: NSInteger,
565            day_value: NSInteger,
566            hour_value: NSInteger,
567            minute_value: NSInteger,
568            second_value: NSInteger,
569            nanosecond_value: NSInteger,
570        ) -> Option<Retained<NSDate>>;
571
572        #[cfg(feature = "NSDate")]
573        #[unsafe(method(dateWithEra:yearForWeekOfYear:weekOfYear:weekday:hour:minute:second:nanosecond:))]
574        #[unsafe(method_family = none)]
575        pub unsafe fn dateWithEra_yearForWeekOfYear_weekOfYear_weekday_hour_minute_second_nanosecond(
576            &self,
577            era_value: NSInteger,
578            year_value: NSInteger,
579            week_value: NSInteger,
580            weekday_value: NSInteger,
581            hour_value: NSInteger,
582            minute_value: NSInteger,
583            second_value: NSInteger,
584            nanosecond_value: NSInteger,
585        ) -> Option<Retained<NSDate>>;
586
587        #[cfg(feature = "NSDate")]
588        #[unsafe(method(startOfDayForDate:))]
589        #[unsafe(method_family = none)]
590        pub unsafe fn startOfDayForDate(&self, date: &NSDate) -> Retained<NSDate>;
591
592        #[cfg(all(feature = "NSDate", feature = "NSTimeZone"))]
593        #[unsafe(method(componentsInTimeZone:fromDate:))]
594        #[unsafe(method_family = none)]
595        pub unsafe fn componentsInTimeZone_fromDate(
596            &self,
597            timezone: &NSTimeZone,
598            date: &NSDate,
599        ) -> Retained<NSDateComponents>;
600
601        #[cfg(all(feature = "NSDate", feature = "NSObjCRuntime"))]
602        #[unsafe(method(compareDate:toDate:toUnitGranularity:))]
603        #[unsafe(method_family = none)]
604        pub unsafe fn compareDate_toDate_toUnitGranularity(
605            &self,
606            date1: &NSDate,
607            date2: &NSDate,
608            unit: NSCalendarUnit,
609        ) -> NSComparisonResult;
610
611        #[cfg(feature = "NSDate")]
612        #[unsafe(method(isDate:equalToDate:toUnitGranularity:))]
613        #[unsafe(method_family = none)]
614        pub unsafe fn isDate_equalToDate_toUnitGranularity(
615            &self,
616            date1: &NSDate,
617            date2: &NSDate,
618            unit: NSCalendarUnit,
619        ) -> bool;
620
621        #[cfg(feature = "NSDate")]
622        #[unsafe(method(isDate:inSameDayAsDate:))]
623        #[unsafe(method_family = none)]
624        pub unsafe fn isDate_inSameDayAsDate(&self, date1: &NSDate, date2: &NSDate) -> bool;
625
626        #[cfg(feature = "NSDate")]
627        #[unsafe(method(isDateInToday:))]
628        #[unsafe(method_family = none)]
629        pub unsafe fn isDateInToday(&self, date: &NSDate) -> bool;
630
631        #[cfg(feature = "NSDate")]
632        #[unsafe(method(isDateInYesterday:))]
633        #[unsafe(method_family = none)]
634        pub unsafe fn isDateInYesterday(&self, date: &NSDate) -> bool;
635
636        #[cfg(feature = "NSDate")]
637        #[unsafe(method(isDateInTomorrow:))]
638        #[unsafe(method_family = none)]
639        pub unsafe fn isDateInTomorrow(&self, date: &NSDate) -> bool;
640
641        #[cfg(feature = "NSDate")]
642        #[unsafe(method(isDateInWeekend:))]
643        #[unsafe(method_family = none)]
644        pub unsafe fn isDateInWeekend(&self, date: &NSDate) -> bool;
645
646        #[cfg(feature = "NSDate")]
647        #[unsafe(method(rangeOfWeekendStartDate:interval:containingDate:))]
648        #[unsafe(method_family = none)]
649        pub unsafe fn rangeOfWeekendStartDate_interval_containingDate(
650            &self,
651            datep: Option<&mut Option<Retained<NSDate>>>,
652            tip: *mut NSTimeInterval,
653            date: &NSDate,
654        ) -> bool;
655
656        #[cfg(feature = "NSDate")]
657        #[unsafe(method(nextWeekendStartDate:interval:options:afterDate:))]
658        #[unsafe(method_family = none)]
659        pub unsafe fn nextWeekendStartDate_interval_options_afterDate(
660            &self,
661            datep: Option<&mut Option<Retained<NSDate>>>,
662            tip: *mut NSTimeInterval,
663            options: NSCalendarOptions,
664            date: &NSDate,
665        ) -> bool;
666
667        #[unsafe(method(components:fromDateComponents:toDateComponents:options:))]
668        #[unsafe(method_family = none)]
669        pub unsafe fn components_fromDateComponents_toDateComponents_options(
670            &self,
671            unit_flags: NSCalendarUnit,
672            starting_date_comp: &NSDateComponents,
673            result_date_comp: &NSDateComponents,
674            options: NSCalendarOptions,
675        ) -> Retained<NSDateComponents>;
676
677        #[cfg(feature = "NSDate")]
678        #[unsafe(method(dateByAddingUnit:value:toDate:options:))]
679        #[unsafe(method_family = none)]
680        pub unsafe fn dateByAddingUnit_value_toDate_options(
681            &self,
682            unit: NSCalendarUnit,
683            value: NSInteger,
684            date: &NSDate,
685            options: NSCalendarOptions,
686        ) -> Option<Retained<NSDate>>;
687
688        #[cfg(all(feature = "NSDate", feature = "block2"))]
689        #[unsafe(method(enumerateDatesStartingAfterDate:matchingComponents:options:usingBlock:))]
690        #[unsafe(method_family = none)]
691        pub unsafe fn enumerateDatesStartingAfterDate_matchingComponents_options_usingBlock(
692            &self,
693            start: &NSDate,
694            comps: &NSDateComponents,
695            opts: NSCalendarOptions,
696            block: &block2::DynBlock<dyn Fn(*mut NSDate, Bool, NonNull<Bool>) + '_>,
697        );
698
699        #[cfg(feature = "NSDate")]
700        #[unsafe(method(nextDateAfterDate:matchingComponents:options:))]
701        #[unsafe(method_family = none)]
702        pub unsafe fn nextDateAfterDate_matchingComponents_options(
703            &self,
704            date: &NSDate,
705            comps: &NSDateComponents,
706            options: NSCalendarOptions,
707        ) -> Option<Retained<NSDate>>;
708
709        #[cfg(feature = "NSDate")]
710        #[unsafe(method(nextDateAfterDate:matchingUnit:value:options:))]
711        #[unsafe(method_family = none)]
712        pub unsafe fn nextDateAfterDate_matchingUnit_value_options(
713            &self,
714            date: &NSDate,
715            unit: NSCalendarUnit,
716            value: NSInteger,
717            options: NSCalendarOptions,
718        ) -> Option<Retained<NSDate>>;
719
720        #[cfg(feature = "NSDate")]
721        #[unsafe(method(nextDateAfterDate:matchingHour:minute:second:options:))]
722        #[unsafe(method_family = none)]
723        pub unsafe fn nextDateAfterDate_matchingHour_minute_second_options(
724            &self,
725            date: &NSDate,
726            hour_value: NSInteger,
727            minute_value: NSInteger,
728            second_value: NSInteger,
729            options: NSCalendarOptions,
730        ) -> Option<Retained<NSDate>>;
731
732        #[cfg(feature = "NSDate")]
733        #[unsafe(method(dateBySettingUnit:value:ofDate:options:))]
734        #[unsafe(method_family = none)]
735        pub unsafe fn dateBySettingUnit_value_ofDate_options(
736            &self,
737            unit: NSCalendarUnit,
738            v: NSInteger,
739            date: &NSDate,
740            opts: NSCalendarOptions,
741        ) -> Option<Retained<NSDate>>;
742
743        #[cfg(feature = "NSDate")]
744        #[unsafe(method(dateBySettingHour:minute:second:ofDate:options:))]
745        #[unsafe(method_family = none)]
746        pub unsafe fn dateBySettingHour_minute_second_ofDate_options(
747            &self,
748            h: NSInteger,
749            m: NSInteger,
750            s: NSInteger,
751            date: &NSDate,
752            opts: NSCalendarOptions,
753        ) -> Option<Retained<NSDate>>;
754
755        #[cfg(feature = "NSDate")]
756        #[unsafe(method(date:matchesComponents:))]
757        #[unsafe(method_family = none)]
758        pub unsafe fn date_matchesComponents(
759            &self,
760            date: &NSDate,
761            components: &NSDateComponents,
762        ) -> bool;
763    );
764}
765
766/// Methods declared on superclass `NSObject`.
767impl NSCalendar {
768    extern_methods!(
769        #[unsafe(method(new))]
770        #[unsafe(method_family = new)]
771        pub unsafe fn new() -> Retained<Self>;
772    );
773}
774
775extern "C" {
776    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nscalendardaychangednotification?language=objc)
777    #[cfg(all(feature = "NSNotification", feature = "NSString"))]
778    pub static NSCalendarDayChangedNotification: &'static NSNotificationName;
779}
780
781/// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsdatecomponentundefined?language=objc)
782pub const NSDateComponentUndefined: NSInteger = NSIntegerMax as _;
783/// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsundefineddatecomponent?language=objc)
784#[deprecated]
785pub const NSUndefinedDateComponent: NSInteger = NSDateComponentUndefined;
786
787extern_class!(
788    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsdatecomponents?language=objc)
789    #[unsafe(super(NSObject))]
790    #[derive(Debug, PartialEq, Eq, Hash)]
791    pub struct NSDateComponents;
792);
793
794#[cfg(feature = "NSObject")]
795extern_conformance!(
796    unsafe impl NSCoding for NSDateComponents {}
797);
798
799#[cfg(feature = "NSObject")]
800extern_conformance!(
801    unsafe impl NSCopying for NSDateComponents {}
802);
803
804#[cfg(feature = "NSObject")]
805unsafe impl CopyingHelper for NSDateComponents {
806    type Result = Self;
807}
808
809extern_conformance!(
810    unsafe impl NSObjectProtocol for NSDateComponents {}
811);
812
813#[cfg(feature = "NSObject")]
814extern_conformance!(
815    unsafe impl NSSecureCoding for NSDateComponents {}
816);
817
818impl NSDateComponents {
819    extern_methods!(
820        #[unsafe(method(calendar))]
821        #[unsafe(method_family = none)]
822        pub unsafe fn calendar(&self) -> Option<Retained<NSCalendar>>;
823
824        /// Setter for [`calendar`][Self::calendar].
825        #[unsafe(method(setCalendar:))]
826        #[unsafe(method_family = none)]
827        pub unsafe fn setCalendar(&self, calendar: Option<&NSCalendar>);
828
829        #[cfg(feature = "NSTimeZone")]
830        #[unsafe(method(timeZone))]
831        #[unsafe(method_family = none)]
832        pub unsafe fn timeZone(&self) -> Option<Retained<NSTimeZone>>;
833
834        #[cfg(feature = "NSTimeZone")]
835        /// Setter for [`timeZone`][Self::timeZone].
836        #[unsafe(method(setTimeZone:))]
837        #[unsafe(method_family = none)]
838        pub unsafe fn setTimeZone(&self, time_zone: Option<&NSTimeZone>);
839
840        #[unsafe(method(era))]
841        #[unsafe(method_family = none)]
842        pub unsafe fn era(&self) -> NSInteger;
843
844        /// Setter for [`era`][Self::era].
845        #[unsafe(method(setEra:))]
846        #[unsafe(method_family = none)]
847        pub unsafe fn setEra(&self, era: NSInteger);
848
849        #[unsafe(method(year))]
850        #[unsafe(method_family = none)]
851        pub unsafe fn year(&self) -> NSInteger;
852
853        /// Setter for [`year`][Self::year].
854        #[unsafe(method(setYear:))]
855        #[unsafe(method_family = none)]
856        pub unsafe fn setYear(&self, year: NSInteger);
857
858        #[unsafe(method(month))]
859        #[unsafe(method_family = none)]
860        pub unsafe fn month(&self) -> NSInteger;
861
862        /// Setter for [`month`][Self::month].
863        #[unsafe(method(setMonth:))]
864        #[unsafe(method_family = none)]
865        pub unsafe fn setMonth(&self, month: NSInteger);
866
867        #[unsafe(method(day))]
868        #[unsafe(method_family = none)]
869        pub unsafe fn day(&self) -> NSInteger;
870
871        /// Setter for [`day`][Self::day].
872        #[unsafe(method(setDay:))]
873        #[unsafe(method_family = none)]
874        pub unsafe fn setDay(&self, day: NSInteger);
875
876        #[unsafe(method(hour))]
877        #[unsafe(method_family = none)]
878        pub unsafe fn hour(&self) -> NSInteger;
879
880        /// Setter for [`hour`][Self::hour].
881        #[unsafe(method(setHour:))]
882        #[unsafe(method_family = none)]
883        pub unsafe fn setHour(&self, hour: NSInteger);
884
885        #[unsafe(method(minute))]
886        #[unsafe(method_family = none)]
887        pub unsafe fn minute(&self) -> NSInteger;
888
889        /// Setter for [`minute`][Self::minute].
890        #[unsafe(method(setMinute:))]
891        #[unsafe(method_family = none)]
892        pub unsafe fn setMinute(&self, minute: NSInteger);
893
894        #[unsafe(method(second))]
895        #[unsafe(method_family = none)]
896        pub unsafe fn second(&self) -> NSInteger;
897
898        /// Setter for [`second`][Self::second].
899        #[unsafe(method(setSecond:))]
900        #[unsafe(method_family = none)]
901        pub unsafe fn setSecond(&self, second: NSInteger);
902
903        #[unsafe(method(nanosecond))]
904        #[unsafe(method_family = none)]
905        pub unsafe fn nanosecond(&self) -> NSInteger;
906
907        /// Setter for [`nanosecond`][Self::nanosecond].
908        #[unsafe(method(setNanosecond:))]
909        #[unsafe(method_family = none)]
910        pub unsafe fn setNanosecond(&self, nanosecond: NSInteger);
911
912        #[unsafe(method(weekday))]
913        #[unsafe(method_family = none)]
914        pub unsafe fn weekday(&self) -> NSInteger;
915
916        /// Setter for [`weekday`][Self::weekday].
917        #[unsafe(method(setWeekday:))]
918        #[unsafe(method_family = none)]
919        pub unsafe fn setWeekday(&self, weekday: NSInteger);
920
921        #[unsafe(method(weekdayOrdinal))]
922        #[unsafe(method_family = none)]
923        pub unsafe fn weekdayOrdinal(&self) -> NSInteger;
924
925        /// Setter for [`weekdayOrdinal`][Self::weekdayOrdinal].
926        #[unsafe(method(setWeekdayOrdinal:))]
927        #[unsafe(method_family = none)]
928        pub unsafe fn setWeekdayOrdinal(&self, weekday_ordinal: NSInteger);
929
930        #[unsafe(method(quarter))]
931        #[unsafe(method_family = none)]
932        pub unsafe fn quarter(&self) -> NSInteger;
933
934        /// Setter for [`quarter`][Self::quarter].
935        #[unsafe(method(setQuarter:))]
936        #[unsafe(method_family = none)]
937        pub unsafe fn setQuarter(&self, quarter: NSInteger);
938
939        #[unsafe(method(weekOfMonth))]
940        #[unsafe(method_family = none)]
941        pub unsafe fn weekOfMonth(&self) -> NSInteger;
942
943        /// Setter for [`weekOfMonth`][Self::weekOfMonth].
944        #[unsafe(method(setWeekOfMonth:))]
945        #[unsafe(method_family = none)]
946        pub unsafe fn setWeekOfMonth(&self, week_of_month: NSInteger);
947
948        #[unsafe(method(weekOfYear))]
949        #[unsafe(method_family = none)]
950        pub unsafe fn weekOfYear(&self) -> NSInteger;
951
952        /// Setter for [`weekOfYear`][Self::weekOfYear].
953        #[unsafe(method(setWeekOfYear:))]
954        #[unsafe(method_family = none)]
955        pub unsafe fn setWeekOfYear(&self, week_of_year: NSInteger);
956
957        #[unsafe(method(yearForWeekOfYear))]
958        #[unsafe(method_family = none)]
959        pub unsafe fn yearForWeekOfYear(&self) -> NSInteger;
960
961        /// Setter for [`yearForWeekOfYear`][Self::yearForWeekOfYear].
962        #[unsafe(method(setYearForWeekOfYear:))]
963        #[unsafe(method_family = none)]
964        pub unsafe fn setYearForWeekOfYear(&self, year_for_week_of_year: NSInteger);
965
966        #[unsafe(method(dayOfYear))]
967        #[unsafe(method_family = none)]
968        pub unsafe fn dayOfYear(&self) -> NSInteger;
969
970        /// Setter for [`dayOfYear`][Self::dayOfYear].
971        #[unsafe(method(setDayOfYear:))]
972        #[unsafe(method_family = none)]
973        pub unsafe fn setDayOfYear(&self, day_of_year: NSInteger);
974
975        #[unsafe(method(isLeapMonth))]
976        #[unsafe(method_family = none)]
977        pub unsafe fn isLeapMonth(&self) -> bool;
978
979        /// Setter for [`isLeapMonth`][Self::isLeapMonth].
980        #[unsafe(method(setLeapMonth:))]
981        #[unsafe(method_family = none)]
982        pub unsafe fn setLeapMonth(&self, leap_month: bool);
983
984        #[cfg(feature = "NSDate")]
985        #[unsafe(method(date))]
986        #[unsafe(method_family = none)]
987        pub unsafe fn date(&self) -> Option<Retained<NSDate>>;
988
989        #[deprecated = "Use -weekOfMonth or -weekOfYear, depending on which you mean"]
990        #[unsafe(method(week))]
991        #[unsafe(method_family = none)]
992        pub unsafe fn week(&self) -> NSInteger;
993
994        #[deprecated = "Use -setWeekOfMonth: or -setWeekOfYear:, depending on which you mean"]
995        #[unsafe(method(setWeek:))]
996        #[unsafe(method_family = none)]
997        pub unsafe fn setWeek(&self, v: NSInteger);
998
999        #[unsafe(method(setValue:forComponent:))]
1000        #[unsafe(method_family = none)]
1001        pub unsafe fn setValue_forComponent(&self, value: NSInteger, unit: NSCalendarUnit);
1002
1003        #[unsafe(method(valueForComponent:))]
1004        #[unsafe(method_family = none)]
1005        pub unsafe fn valueForComponent(&self, unit: NSCalendarUnit) -> NSInteger;
1006
1007        #[unsafe(method(isValidDate))]
1008        #[unsafe(method_family = none)]
1009        pub unsafe fn isValidDate(&self) -> bool;
1010
1011        #[unsafe(method(isValidDateInCalendar:))]
1012        #[unsafe(method_family = none)]
1013        pub unsafe fn isValidDateInCalendar(&self, calendar: &NSCalendar) -> bool;
1014    );
1015}
1016
1017/// Methods declared on superclass `NSObject`.
1018impl NSDateComponents {
1019    extern_methods!(
1020        #[unsafe(method(init))]
1021        #[unsafe(method_family = init)]
1022        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
1023
1024        #[unsafe(method(new))]
1025        #[unsafe(method_family = new)]
1026        pub unsafe fn new() -> Retained<Self>;
1027    );
1028}