1use core::num::NonZero;
4
5macro_rules! if_pub {
7 (pub $(#[$attr:meta])*; $($x:tt)*) => {
8 $(#[$attr])*
9 $($x)*
16 };
17 ($($_:tt)*) => {};
18}
19
20macro_rules! impl_const_default {
24 ($($(
25 #[doc = $doc:expr])*
26 $(#[cfg($($cfg:tt)+)])?
27 $(#[expect($($expected:tt)+)])?
28 $(@$pub:ident)? $type:ty => $default:expr;
29 )*) => {$(
30 $(#[cfg($($cfg)+)])?
31 $(#[expect($($expected)+)])?
32 impl $type {
33 if_pub! {
34 $($pub)?
35 $(#[doc = $doc])*;
36 #[inline]
37 pub const fn default() -> Self {
38 $default
39 }
40 }
41 }
42
43 $(#[doc = $doc])*
44 $(#[cfg($($cfg)+)])?
45 $(#[expect($($expected)+)])?
46 impl Default for $type {
47 #[inline]
48 fn default() -> Self {
49 $default
50 }
51 }
52 )*};
53}
54
55impl_const_default! {
57 @pub Day => Self { padding: Padding::Zero };
59 #[expect(deprecated)]
62 MonthRepr => Self::Numerical;
63 @pub MonthShort => Self { case_sensitive: true };
64 @pub MonthLong => Self { case_sensitive: true };
65 @pub MonthNumerical => Self { padding: Padding::Zero };
66 #[expect(deprecated)]
70 @pub Month => Self {
71 padding: Padding::Zero,
72 repr: MonthRepr::Numerical,
73 case_sensitive: true,
74 };
75 @pub Ordinal => Self { padding: Padding::Zero };
77 #[expect(deprecated)]
79 WeekdayRepr => Self::Long;
80 @pub WeekdayShort => Self { case_sensitive: true };
81 @pub WeekdayLong => Self { case_sensitive: true };
82 @pub WeekdaySunday => Self { one_indexed: true };
83 @pub WeekdayMonday => Self { one_indexed: true };
84 #[expect(deprecated)]
88 @pub Weekday => Self {
89 repr: WeekdayRepr::Long,
90 one_indexed: true,
91 case_sensitive: true,
92 };
93 #[expect(deprecated)]
95 WeekNumberRepr => Self::Iso;
96 @pub WeekNumberIso => Self { padding: Padding::Zero };
97 @pub WeekNumberSunday => Self { padding: Padding::Zero };
98 @pub WeekNumberMonday => Self { padding: Padding::Zero };
99 #[expect(deprecated)]
102 @pub WeekNumber => Self {
103 padding: Padding::Zero,
104 repr: WeekNumberRepr::Iso,
105 };
106 #[expect(deprecated)]
108 YearRepr => Self::Full;
109 #[expect(deprecated)]
111 YearRange => Self::Extended;
112 @pub CalendarYearFullExtendedRange => Self {
113 padding: Padding::Zero,
114 sign_is_mandatory: false,
115 };
116 @pub CalendarYearFullStandardRange => Self {
117 padding: Padding::Zero,
118 sign_is_mandatory: false,
119 };
120 @pub IsoYearFullExtendedRange => Self {
121 padding: Padding::Zero,
122 sign_is_mandatory: false,
123 };
124 @pub IsoYearFullStandardRange => Self {
125 padding: Padding::Zero,
126 sign_is_mandatory: false,
127 };
128 @pub CalendarYearCenturyExtendedRange => Self {
129 padding: Padding::Zero,
130 sign_is_mandatory: false,
131 };
132 @pub CalendarYearCenturyStandardRange => Self {
133 padding: Padding::Zero,
134 sign_is_mandatory: false,
135 };
136 @pub IsoYearCenturyExtendedRange => Self {
137 padding: Padding::Zero,
138 sign_is_mandatory: false,
139 };
140 @pub IsoYearCenturyStandardRange => Self {
141 padding: Padding::Zero,
142 sign_is_mandatory: false,
143 };
144 @pub CalendarYearLastTwo => Self {
145 padding: Padding::Zero,
146 };
147 @pub IsoYearLastTwo => Self {
148 padding: Padding::Zero,
149 };
150 #[expect(deprecated)]
154 @pub Year => Self {
155 padding: Padding::Zero,
156 repr: YearRepr::Full,
157 range: YearRange::Extended,
158 iso_week_based: false,
159 sign_is_mandatory: false,
160 };
161 @pub Hour12 => Self { padding: Padding::Zero };
162 @pub Hour24 => Self { padding: Padding::Zero };
163 #[expect(deprecated)]
166 @pub Hour => Self {
167 padding: Padding::Zero,
168 is_12_hour_clock: false,
169 };
170 @pub Minute => Self { padding: Padding::Zero };
172 @pub Period => Self {
175 is_uppercase: true,
176 case_sensitive: true,
177 };
178 @pub Second => Self { padding: Padding::Zero };
180 SubsecondDigits => Self::OneOrMore;
183 @pub Subsecond => Self { digits: SubsecondDigits::OneOrMore };
186 @pub OffsetHour => Self {
189 sign_is_mandatory: false,
190 padding: Padding::Zero,
191 };
192 @pub OffsetMinute => Self { padding: Padding::Zero };
194 @pub OffsetSecond => Self { padding: Padding::Zero };
196 Padding => Self::Zero;
198 #[expect(deprecated)]
201 UnixTimestampPrecision => Self::Second;
202 @pub UnixTimestampSecond => Self { sign_is_mandatory: false };
203 @pub UnixTimestampMillisecond => Self { sign_is_mandatory: false };
204 @pub UnixTimestampMicrosecond => Self { sign_is_mandatory: false };
205 @pub UnixTimestampNanosecond => Self { sign_is_mandatory: false };
206 #[expect(deprecated)]
209 @pub UnixTimestamp => Self {
210 precision: UnixTimestampPrecision::Second,
211 sign_is_mandatory: false,
212 };
213 TrailingInput => Self::Prohibit;
216 @pub End => Self { trailing_input: TrailingInput::Prohibit };
219}
220
221#[non_exhaustive]
223#[derive(Debug, Clone, Copy, PartialEq, Eq)]
224pub struct Day {
225 pub padding: Padding,
227}
228
229impl Day {
230 #[inline]
232 #[must_use = "this returns the result of the operation, without modifying the original"]
233 pub const fn with_padding(self, padding: Padding) -> Self {
234 Self { padding }
235 }
236}
237
238#[non_exhaustive]
240#[deprecated(
241 since = "0.3.48",
242 note = "used only in the deprecated `Month` component"
243)]
244#[derive(Debug, Clone, Copy, PartialEq, Eq)]
245pub enum MonthRepr {
246 Numerical,
248 Long,
250 Short,
252}
253
254#[derive(Debug, Clone, Copy, PartialEq, Eq)]
256pub struct MonthShort {
257 pub(crate) case_sensitive: bool,
259}
260
261impl MonthShort {
262 #[inline]
264 #[must_use = "this returns the result of the operation, without modifying the original"]
265 pub const fn with_case_sensitive(self, case_sensitive: bool) -> Self {
266 Self { case_sensitive }
267 }
268}
269
270#[derive(Debug, Clone, Copy, PartialEq, Eq)]
272pub struct MonthLong {
273 pub(crate) case_sensitive: bool,
275}
276
277impl MonthLong {
278 #[inline]
280 #[must_use = "this returns the result of the operation, without modifying the original"]
281 pub const fn with_case_sensitive(self, case_sensitive: bool) -> Self {
282 Self { case_sensitive }
283 }
284}
285
286#[derive(Debug, Clone, Copy, PartialEq, Eq)]
288pub struct MonthNumerical {
289 pub(crate) padding: Padding,
291}
292
293impl MonthNumerical {
294 #[inline]
296 #[must_use = "this returns the result of the operation, without modifying the original"]
297 pub const fn with_padding(self, padding: Padding) -> Self {
298 Self { padding }
299 }
300}
301
302#[non_exhaustive]
304#[allow(deprecated)]
305#[deprecated(
306 since = "0.3.48",
307 note = "use `MonthShort`, `MonthLong`, or `MonthNumeric` instead"
308)]
309#[derive(Debug, Clone, Copy, PartialEq, Eq)]
310pub struct Month {
311 pub padding: Padding,
313 pub repr: MonthRepr,
315 pub case_sensitive: bool,
317}
318
319#[expect(deprecated)]
320impl Month {
321 #[inline]
323 #[must_use = "this returns the result of the operation, without modifying the original"]
324 pub const fn with_padding(self, padding: Padding) -> Self {
325 Self { padding, ..self }
326 }
327
328 #[inline]
330 #[must_use = "this returns the result of the operation, without modifying the original"]
331 pub const fn with_repr(self, repr: MonthRepr) -> Self {
332 Self { repr, ..self }
333 }
334
335 #[inline]
337 #[must_use = "this returns the result of the operation, without modifying the original"]
338 pub const fn with_case_sensitive(self, case_sensitive: bool) -> Self {
339 Self {
340 case_sensitive,
341 ..self
342 }
343 }
344}
345
346#[non_exhaustive]
348#[derive(Debug, Clone, Copy, PartialEq, Eq)]
349pub struct Ordinal {
350 pub padding: Padding,
352}
353
354impl Ordinal {
355 #[inline]
357 #[must_use = "this returns the result of the operation, without modifying the original"]
358 pub const fn with_padding(self, padding: Padding) -> Self {
359 Self { padding }
360 }
361}
362
363#[non_exhaustive]
365#[deprecated(
366 since = "0.3.48",
367 note = "used only in the deprecated `Weekday` component"
368)]
369#[derive(Debug, Clone, Copy, PartialEq, Eq)]
370pub enum WeekdayRepr {
371 Short,
373 Long,
375 Sunday,
379 Monday,
383}
384
385#[derive(Debug, Clone, Copy, PartialEq, Eq)]
387pub struct WeekdayShort {
388 pub(crate) case_sensitive: bool,
390}
391
392impl WeekdayShort {
393 #[inline]
395 #[must_use = "this returns the result of the operation, without modifying the original"]
396 pub const fn with_case_sensitive(self, case_sensitive: bool) -> Self {
397 Self { case_sensitive }
398 }
399}
400
401#[derive(Debug, Clone, Copy, PartialEq, Eq)]
403pub struct WeekdayLong {
404 pub(crate) case_sensitive: bool,
406}
407
408impl WeekdayLong {
409 #[inline]
411 #[must_use = "this returns the result of the operation, without modifying the original"]
412 pub const fn with_case_sensitive(self, case_sensitive: bool) -> Self {
413 Self { case_sensitive }
414 }
415}
416
417#[derive(Debug, Clone, Copy, PartialEq, Eq)]
419pub struct WeekdaySunday {
420 pub(crate) one_indexed: bool,
422}
423
424impl WeekdaySunday {
425 #[inline]
427 #[must_use = "this returns the result of the operation, without modifying the original"]
428 pub const fn with_one_indexed(self, one_indexed: bool) -> Self {
429 Self { one_indexed }
430 }
431}
432
433#[derive(Debug, Clone, Copy, PartialEq, Eq)]
435pub struct WeekdayMonday {
436 pub(crate) one_indexed: bool,
438}
439
440impl WeekdayMonday {
441 #[inline]
443 #[must_use = "this returns the result of the operation, without modifying the original"]
444 pub const fn with_one_indexed(self, one_indexed: bool) -> Self {
445 Self { one_indexed }
446 }
447}
448
449#[non_exhaustive]
451#[allow(deprecated)]
452#[deprecated(
453 since = "0.3.48",
454 note = "use `WeekdayShort`, `WeekdayLong`, `WeekdaySunday`, or `WeekdayMonday` instead"
455)]
456#[derive(Debug, Clone, Copy, PartialEq, Eq)]
457pub struct Weekday {
458 pub repr: WeekdayRepr,
460 pub one_indexed: bool,
462 pub case_sensitive: bool,
464}
465
466#[expect(deprecated)]
467impl Weekday {
468 #[inline]
470 #[must_use = "this returns the result of the operation, without modifying the original"]
471 pub const fn with_repr(self, repr: WeekdayRepr) -> Self {
472 Self { repr, ..self }
473 }
474
475 #[inline]
477 #[must_use = "this returns the result of the operation, without modifying the original"]
478 pub const fn with_one_indexed(self, one_indexed: bool) -> Self {
479 Self {
480 one_indexed,
481 ..self
482 }
483 }
484
485 #[inline]
487 #[must_use = "this returns the result of the operation, without modifying the original"]
488 pub const fn with_case_sensitive(self, case_sensitive: bool) -> Self {
489 Self {
490 case_sensitive,
491 ..self
492 }
493 }
494}
495
496#[non_exhaustive]
498#[deprecated(
499 since = "0.3.48",
500 note = "used only in the deprecated `WeekNumber` component"
501)]
502#[derive(Debug, Clone, Copy, PartialEq, Eq)]
503pub enum WeekNumberRepr {
504 Iso,
506 Sunday,
508 Monday,
510}
511
512#[derive(Debug, Clone, Copy, PartialEq, Eq)]
516pub struct WeekNumberIso {
517 pub padding: Padding,
519}
520
521impl WeekNumberIso {
522 #[inline]
524 #[must_use = "this returns the result of the operation, without modifying the original"]
525 pub const fn with_padding(self, padding: Padding) -> Self {
526 Self { padding }
527 }
528}
529
530#[derive(Debug, Clone, Copy, PartialEq, Eq)]
534pub struct WeekNumberSunday {
535 pub padding: Padding,
537}
538
539impl WeekNumberSunday {
540 #[inline]
542 #[must_use = "this returns the result of the operation, without modifying the original"]
543 pub const fn with_padding(self, padding: Padding) -> Self {
544 Self { padding }
545 }
546}
547
548#[derive(Debug, Clone, Copy, PartialEq, Eq)]
552pub struct WeekNumberMonday {
553 pub padding: Padding,
555}
556
557impl WeekNumberMonday {
558 #[inline]
560 #[must_use = "this returns the result of the operation, without modifying the original"]
561 pub const fn with_padding(self, padding: Padding) -> Self {
562 Self { padding }
563 }
564}
565
566#[non_exhaustive]
568#[allow(deprecated)]
569#[deprecated(
570 since = "0.3.48",
571 note = "use `WeekNumberIso`, `WeekNumberSunday`, or `WeekNumberMonday` instead"
572)]
573#[derive(Debug, Clone, Copy, PartialEq, Eq)]
574pub struct WeekNumber {
575 pub padding: Padding,
577 pub repr: WeekNumberRepr,
579}
580
581#[expect(deprecated)]
582impl WeekNumber {
583 #[inline]
585 #[must_use = "this returns the result of the operation, without modifying the original"]
586 pub const fn with_padding(self, padding: Padding) -> Self {
587 Self { padding, ..self }
588 }
589
590 #[inline]
592 #[must_use = "this returns the result of the operation, without modifying the original"]
593 pub const fn with_repr(self, repr: WeekNumberRepr) -> Self {
594 Self { repr, ..self }
595 }
596}
597
598#[non_exhaustive]
600#[deprecated(
601 since = "0.3.48",
602 note = "used only in the deprecated `Year` component"
603)]
604#[derive(Debug, Clone, Copy, PartialEq, Eq)]
605pub enum YearRepr {
606 Full,
608 Century,
610 LastTwo,
612}
613
614#[non_exhaustive]
618#[deprecated(
619 since = "0.3.48",
620 note = "used only in the deprecated `Year` component"
621)]
622#[derive(Debug, Clone, Copy, PartialEq, Eq)]
623pub enum YearRange {
624 Standard,
626 Extended,
631}
632
633#[derive(Debug, Clone, Copy, PartialEq, Eq)]
636pub struct CalendarYearFullExtendedRange {
637 pub(crate) padding: Padding,
639 pub(crate) sign_is_mandatory: bool,
642}
643
644impl CalendarYearFullExtendedRange {
645 #[inline]
647 #[must_use = "this returns the result of the operation, without modifying the original"]
648 pub const fn with_padding(self, padding: Padding) -> Self {
649 Self { padding, ..self }
650 }
651
652 #[inline]
654 #[must_use = "this returns the result of the operation, without modifying the original"]
655 pub const fn with_sign_is_mandatory(self, sign_is_mandatory: bool) -> Self {
656 Self {
657 sign_is_mandatory,
658 ..self
659 }
660 }
661}
662
663#[derive(Debug, Clone, Copy, PartialEq, Eq)]
666pub struct CalendarYearFullStandardRange {
667 pub(crate) padding: Padding,
669 pub(crate) sign_is_mandatory: bool,
672}
673
674impl CalendarYearFullStandardRange {
675 #[inline]
677 #[must_use = "this returns the result of the operation, without modifying the original"]
678 pub const fn with_padding(self, padding: Padding) -> Self {
679 Self { padding, ..self }
680 }
681
682 #[inline]
684 #[must_use = "this returns the result of the operation, without modifying the original"]
685 pub const fn with_sign_is_mandatory(self, sign_is_mandatory: bool) -> Self {
686 Self {
687 sign_is_mandatory,
688 ..self
689 }
690 }
691}
692
693#[derive(Debug, Clone, Copy, PartialEq, Eq)]
696pub struct IsoYearFullExtendedRange {
697 pub(crate) padding: Padding,
699 pub(crate) sign_is_mandatory: bool,
702}
703
704impl IsoYearFullExtendedRange {
705 #[inline]
707 #[must_use = "this returns the result of the operation, without modifying the original"]
708 pub const fn with_padding(self, padding: Padding) -> Self {
709 Self { padding, ..self }
710 }
711
712 #[inline]
714 #[must_use = "this returns the result of the operation, without modifying the original"]
715 pub const fn with_sign_is_mandatory(self, sign_is_mandatory: bool) -> Self {
716 Self {
717 sign_is_mandatory,
718 ..self
719 }
720 }
721}
722
723#[derive(Debug, Clone, Copy, PartialEq, Eq)]
726pub struct IsoYearFullStandardRange {
727 pub(crate) padding: Padding,
729 pub(crate) sign_is_mandatory: bool,
732}
733
734impl IsoYearFullStandardRange {
735 #[inline]
737 #[must_use = "this returns the result of the operation, without modifying the original"]
738 pub const fn with_padding(self, padding: Padding) -> Self {
739 Self { padding, ..self }
740 }
741
742 #[inline]
744 #[must_use = "this returns the result of the operation, without modifying the original"]
745 pub const fn with_sign_is_mandatory(self, sign_is_mandatory: bool) -> Self {
746 Self {
747 sign_is_mandatory,
748 ..self
749 }
750 }
751}
752
753#[derive(Debug, Clone, Copy, PartialEq, Eq)]
756pub struct CalendarYearCenturyExtendedRange {
757 pub(crate) padding: Padding,
759 pub(crate) sign_is_mandatory: bool,
762}
763
764impl CalendarYearCenturyExtendedRange {
765 #[inline]
767 #[must_use = "this returns the result of the operation, without modifying the original"]
768 pub const fn with_padding(self, padding: Padding) -> Self {
769 Self { padding, ..self }
770 }
771
772 #[inline]
774 #[must_use = "this returns the result of the operation, without modifying the original"]
775 pub const fn with_sign_is_mandatory(self, sign_is_mandatory: bool) -> Self {
776 Self {
777 sign_is_mandatory,
778 ..self
779 }
780 }
781}
782
783#[derive(Debug, Clone, Copy, PartialEq, Eq)]
786pub struct CalendarYearCenturyStandardRange {
787 pub(crate) padding: Padding,
789 pub(crate) sign_is_mandatory: bool,
792}
793
794impl CalendarYearCenturyStandardRange {
795 #[inline]
797 #[must_use = "this returns the result of the operation, without modifying the original"]
798 pub const fn with_padding(self, padding: Padding) -> Self {
799 Self { padding, ..self }
800 }
801
802 #[inline]
804 #[must_use = "this returns the result of the operation, without modifying the original"]
805 pub const fn with_sign_is_mandatory(self, sign_is_mandatory: bool) -> Self {
806 Self {
807 sign_is_mandatory,
808 ..self
809 }
810 }
811}
812
813#[derive(Debug, Clone, Copy, PartialEq, Eq)]
816pub struct IsoYearCenturyExtendedRange {
817 pub(crate) padding: Padding,
819 pub(crate) sign_is_mandatory: bool,
822}
823
824impl IsoYearCenturyExtendedRange {
825 #[inline]
827 #[must_use = "this returns the result of the operation, without modifying the original"]
828 pub const fn with_padding(self, padding: Padding) -> Self {
829 Self { padding, ..self }
830 }
831
832 #[inline]
834 #[must_use = "this returns the result of the operation, without modifying the original"]
835 pub const fn with_sign_is_mandatory(self, sign_is_mandatory: bool) -> Self {
836 Self {
837 sign_is_mandatory,
838 ..self
839 }
840 }
841}
842
843#[derive(Debug, Clone, Copy, PartialEq, Eq)]
846pub struct IsoYearCenturyStandardRange {
847 pub(crate) padding: Padding,
849 pub(crate) sign_is_mandatory: bool,
852}
853
854impl IsoYearCenturyStandardRange {
855 #[inline]
857 #[must_use = "this returns the result of the operation, without modifying the original"]
858 pub const fn with_padding(self, padding: Padding) -> Self {
859 Self { padding, ..self }
860 }
861
862 #[inline]
864 #[must_use = "this returns the result of the operation, without modifying the original"]
865 pub const fn with_sign_is_mandatory(self, sign_is_mandatory: bool) -> Self {
866 Self {
867 sign_is_mandatory,
868 ..self
869 }
870 }
871}
872
873#[non_exhaustive]
875#[derive(Debug, Clone, Copy, PartialEq, Eq)]
876pub struct CalendarYearLastTwo {
877 pub(crate) padding: Padding,
879}
880
881impl CalendarYearLastTwo {
882 #[inline]
884 #[must_use = "this returns the result of the operation, without modifying the original"]
885 pub const fn with_padding(self, padding: Padding) -> Self {
886 Self { padding }
887 }
888}
889
890#[non_exhaustive]
893#[derive(Debug, Clone, Copy, PartialEq, Eq)]
894pub struct IsoYearLastTwo {
895 pub(crate) padding: Padding,
897}
898
899impl IsoYearLastTwo {
900 #[inline]
902 #[must_use = "this returns the result of the operation, without modifying the original"]
903 pub const fn with_padding(self, padding: Padding) -> Self {
904 Self { padding }
905 }
906}
907
908#[non_exhaustive]
910#[allow(deprecated)]
911#[deprecated(
912 since = "0.3.48",
913 note = "use one of the various `Year*` components instead"
914)]
915#[derive(Debug, Clone, Copy, PartialEq, Eq)]
916pub struct Year {
917 pub padding: Padding,
919 pub repr: YearRepr,
921 pub range: YearRange,
923 pub iso_week_based: bool,
925 pub sign_is_mandatory: bool,
928}
929
930#[expect(deprecated)]
931impl Year {
932 #[inline]
934 #[must_use = "this returns the result of the operation, without modifying the original"]
935 pub const fn with_padding(self, padding: Padding) -> Self {
936 Self { padding, ..self }
937 }
938
939 #[inline]
941 #[must_use = "this returns the result of the operation, without modifying the original"]
942 pub const fn with_repr(self, repr: YearRepr) -> Self {
943 Self { repr, ..self }
944 }
945
946 #[inline]
948 #[must_use = "this returns the result of the operation, without modifying the original"]
949 pub const fn with_range(self, range: YearRange) -> Self {
950 Self { range, ..self }
951 }
952
953 #[inline]
955 #[must_use = "this returns the result of the operation, without modifying the original"]
956 pub const fn with_iso_week_based(self, iso_week_based: bool) -> Self {
957 Self {
958 iso_week_based,
959 ..self
960 }
961 }
962
963 #[inline]
965 #[must_use = "this returns the result of the operation, without modifying the original"]
966 pub const fn with_sign_is_mandatory(self, sign_is_mandatory: bool) -> Self {
967 Self {
968 sign_is_mandatory,
969 ..self
970 }
971 }
972}
973
974#[derive(Debug, Clone, Copy, PartialEq, Eq)]
976pub struct Hour12 {
977 pub(crate) padding: Padding,
979}
980
981impl Hour12 {
982 #[inline]
984 #[must_use = "this returns the result of the operation, without modifying the original"]
985 pub const fn with_padding(self, padding: Padding) -> Self {
986 Self { padding }
987 }
988}
989
990#[derive(Debug, Clone, Copy, PartialEq, Eq)]
992pub struct Hour24 {
993 pub(crate) padding: Padding,
995}
996
997impl Hour24 {
998 #[inline]
1000 #[must_use = "this returns the result of the operation, without modifying the original"]
1001 pub const fn with_padding(self, padding: Padding) -> Self {
1002 Self { padding }
1003 }
1004}
1005
1006#[non_exhaustive]
1008#[deprecated(since = "0.3.48", note = "use `Hour12` or `Hour24` instead")]
1009#[derive(Debug, Clone, Copy, PartialEq, Eq)]
1010pub struct Hour {
1011 pub padding: Padding,
1013 pub is_12_hour_clock: bool,
1015}
1016
1017#[expect(deprecated)]
1018impl Hour {
1019 #[inline]
1021 #[must_use = "this returns the result of the operation, without modifying the original"]
1022 pub const fn with_padding(self, padding: Padding) -> Self {
1023 Self { padding, ..self }
1024 }
1025
1026 #[inline]
1028 #[must_use = "this returns the result of the operation, without modifying the original"]
1029 pub const fn with_is_12_hour_clock(self, is_12_hour_clock: bool) -> Self {
1030 Self {
1031 is_12_hour_clock,
1032 ..self
1033 }
1034 }
1035}
1036
1037#[non_exhaustive]
1039#[derive(Debug, Clone, Copy, PartialEq, Eq)]
1040pub struct Minute {
1041 pub padding: Padding,
1043}
1044
1045impl Minute {
1046 #[inline]
1048 #[must_use = "this returns the result of the operation, without modifying the original"]
1049 pub const fn with_padding(self, padding: Padding) -> Self {
1050 Self { padding }
1051 }
1052}
1053
1054#[non_exhaustive]
1056#[derive(Debug, Clone, Copy, PartialEq, Eq)]
1057pub struct Period {
1058 pub is_uppercase: bool,
1060 pub case_sensitive: bool,
1064}
1065
1066impl Period {
1067 #[inline]
1069 #[must_use = "this returns the result of the operation, without modifying the original"]
1070 pub const fn with_is_uppercase(self, is_uppercase: bool) -> Self {
1071 Self {
1072 is_uppercase,
1073 ..self
1074 }
1075 }
1076
1077 #[inline]
1079 #[must_use = "this returns the result of the operation, without modifying the original"]
1080 pub const fn with_case_sensitive(self, case_sensitive: bool) -> Self {
1081 Self {
1082 case_sensitive,
1083 ..self
1084 }
1085 }
1086}
1087
1088#[non_exhaustive]
1090#[derive(Debug, Clone, Copy, PartialEq, Eq)]
1091pub struct Second {
1092 pub padding: Padding,
1094}
1095
1096impl Second {
1097 #[inline]
1099 #[must_use = "this returns the result of the operation, without modifying the original"]
1100 pub const fn with_padding(self, padding: Padding) -> Self {
1101 Self { padding }
1102 }
1103}
1104
1105#[non_exhaustive]
1107#[derive(Debug, Clone, Copy, PartialEq, Eq)]
1108pub enum SubsecondDigits {
1109 One,
1111 Two,
1113 Three,
1115 Four,
1117 Five,
1119 Six,
1121 Seven,
1123 Eight,
1125 Nine,
1127 OneOrMore,
1130}
1131
1132#[non_exhaustive]
1134#[derive(Debug, Clone, Copy, PartialEq, Eq)]
1135pub struct Subsecond {
1136 pub digits: SubsecondDigits,
1138}
1139
1140impl Subsecond {
1141 #[inline]
1143 #[must_use = "this returns the result of the operation, without modifying the original"]
1144 pub const fn with_digits(self, digits: SubsecondDigits) -> Self {
1145 Self { digits }
1146 }
1147}
1148
1149#[non_exhaustive]
1151#[derive(Debug, Clone, Copy, PartialEq, Eq)]
1152pub struct OffsetHour {
1153 pub sign_is_mandatory: bool,
1155 pub padding: Padding,
1157}
1158
1159impl OffsetHour {
1160 #[inline]
1162 #[must_use = "this returns the result of the operation, without modifying the original"]
1163 pub const fn with_sign_is_mandatory(self, sign_is_mandatory: bool) -> Self {
1164 Self {
1165 sign_is_mandatory,
1166 ..self
1167 }
1168 }
1169
1170 #[inline]
1172 #[must_use = "this returns the result of the operation, without modifying the original"]
1173 pub const fn with_padding(self, padding: Padding) -> Self {
1174 Self { padding, ..self }
1175 }
1176}
1177
1178#[non_exhaustive]
1180#[derive(Debug, Clone, Copy, PartialEq, Eq)]
1181pub struct OffsetMinute {
1182 pub padding: Padding,
1184}
1185
1186impl OffsetMinute {
1187 #[inline]
1189 #[must_use = "this returns the result of the operation, without modifying the original"]
1190 pub const fn with_padding(self, padding: Padding) -> Self {
1191 Self { padding }
1192 }
1193}
1194
1195#[non_exhaustive]
1197#[derive(Debug, Clone, Copy, PartialEq, Eq)]
1198pub struct OffsetSecond {
1199 pub padding: Padding,
1201}
1202
1203impl OffsetSecond {
1204 #[inline]
1206 #[must_use = "this returns the result of the operation, without modifying the original"]
1207 pub const fn with_padding(self, padding: Padding) -> Self {
1208 Self { padding }
1209 }
1210}
1211
1212#[non_exhaustive]
1214#[derive(Debug, Clone, Copy, PartialEq, Eq)]
1215pub enum Padding {
1216 Space,
1218 Zero,
1220 None,
1223}
1224
1225#[non_exhaustive]
1229#[derive(Debug, Clone, Copy, PartialEq, Eq)]
1230pub struct Ignore {
1231 pub count: NonZero<u16>,
1233}
1234
1235impl Ignore {
1238 #[inline]
1240 pub const fn count(count: NonZero<u16>) -> Self {
1241 Self { count }
1242 }
1243
1244 #[inline]
1246 #[must_use = "this returns the result of the operation, without modifying the original"]
1247 pub const fn with_count(self, count: NonZero<u16>) -> Self {
1248 Self { count }
1249 }
1250}
1251
1252#[non_exhaustive]
1254#[deprecated(
1255 since = "0.3.48",
1256 note = "only used in the deprecated `UnixTimestamp` component"
1257)]
1258#[derive(Debug, Clone, Copy, PartialEq, Eq)]
1259pub enum UnixTimestampPrecision {
1260 Second,
1262 Millisecond,
1264 Microsecond,
1266 Nanosecond,
1268}
1269
1270#[derive(Debug, Clone, Copy, PartialEq, Eq)]
1272pub struct UnixTimestampSecond {
1273 pub(crate) sign_is_mandatory: bool,
1275}
1276
1277impl UnixTimestampSecond {
1278 #[inline]
1280 #[must_use = "this returns the result of the operation, without modifying the original"]
1281 pub const fn with_sign_is_mandatory(self, sign_is_mandatory: bool) -> Self {
1282 Self { sign_is_mandatory }
1283 }
1284}
1285
1286#[derive(Debug, Clone, Copy, PartialEq, Eq)]
1288pub struct UnixTimestampMillisecond {
1289 pub(crate) sign_is_mandatory: bool,
1291}
1292
1293impl UnixTimestampMillisecond {
1294 #[inline]
1296 #[must_use = "this returns the result of the operation, without modifying the original"]
1297 pub const fn with_sign_is_mandatory(self, sign_is_mandatory: bool) -> Self {
1298 Self { sign_is_mandatory }
1299 }
1300}
1301
1302#[derive(Debug, Clone, Copy, PartialEq, Eq)]
1304pub struct UnixTimestampMicrosecond {
1305 pub(crate) sign_is_mandatory: bool,
1307}
1308
1309impl UnixTimestampMicrosecond {
1310 #[inline]
1312 #[must_use = "this returns the result of the operation, without modifying the original"]
1313 pub const fn with_sign_is_mandatory(self, sign_is_mandatory: bool) -> Self {
1314 Self { sign_is_mandatory }
1315 }
1316}
1317
1318#[derive(Debug, Clone, Copy, PartialEq, Eq)]
1320pub struct UnixTimestampNanosecond {
1321 pub(crate) sign_is_mandatory: bool,
1323}
1324
1325impl UnixTimestampNanosecond {
1326 #[inline]
1328 #[must_use = "this returns the result of the operation, without modifying the original"]
1329 pub const fn with_sign_is_mandatory(self, sign_is_mandatory: bool) -> Self {
1330 Self { sign_is_mandatory }
1331 }
1332}
1333
1334#[non_exhaustive]
1336#[allow(deprecated)]
1337#[deprecated(
1338 since = "0.3.48",
1339 note = "use `UnixTimestampSeconds`, `UnixTimestampMilliseconds`, `UnixTimestampMicroseconds`, \
1340 or `UnixTimestampNanoseconds` instead"
1341)]
1342#[derive(Debug, Clone, Copy, PartialEq, Eq)]
1343pub struct UnixTimestamp {
1344 pub precision: UnixTimestampPrecision,
1346 pub sign_is_mandatory: bool,
1348}
1349
1350#[expect(deprecated)]
1351impl UnixTimestamp {
1352 #[inline]
1354 #[must_use = "this returns the result of the operation, without modifying the original"]
1355 pub const fn with_precision(self, precision: UnixTimestampPrecision) -> Self {
1356 Self { precision, ..self }
1357 }
1358
1359 #[inline]
1361 #[must_use = "this returns the result of the operation, without modifying the original"]
1362 pub const fn with_sign_is_mandatory(self, sign_is_mandatory: bool) -> Self {
1363 Self {
1364 sign_is_mandatory,
1365 ..self
1366 }
1367 }
1368}
1369
1370#[derive(Debug, Clone, Copy, PartialEq, Eq)]
1372pub enum TrailingInput {
1373 Prohibit,
1375 Discard,
1377}
1378
1379#[non_exhaustive]
1381#[derive(Debug, Clone, Copy, PartialEq, Eq)]
1382pub struct End {
1383 pub(crate) trailing_input: TrailingInput,
1385}
1386
1387impl End {
1388 #[inline]
1390 #[must_use = "this returns the result of the operation, without modifying the original"]
1391 pub const fn with_trailing_input(self, trailing_input: TrailingInput) -> Self {
1392 Self {
1393 trailing_input,
1394 ..self
1395 }
1396 }
1397}