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