Skip to main content

time/format_description/
component.rs

1//! Part of a format description.
2
3use crate::format_description::modifier;
4
5/// Indicate whether the hour is "am" or "pm".
6#[derive(Debug, Clone, Copy, PartialEq, Eq)]
7pub(crate) enum Period {
8    #[allow(clippy::missing_docs_in_private_items)]
9    Am,
10    #[allow(clippy::missing_docs_in_private_items)]
11    Pm,
12}
13
14/// A component of a larger format description.
15#[non_exhaustive]
16#[derive(Debug, Clone, Copy, PartialEq, Eq)]
17pub enum Component {
18    /// Day of the month.
19    Day(modifier::Day),
20    /// Month of the year.
21    Month(modifier::Month),
22    /// Ordinal day of the year.
23    Ordinal(modifier::Ordinal),
24    /// Day of the week.
25    Weekday(modifier::Weekday),
26    /// Week within the year.
27    WeekNumber(modifier::WeekNumber),
28    /// Year of the date.
29    Year(modifier::Year),
30    /// Hour of the day.
31    Hour(modifier::Hour),
32    /// Minute within the hour.
33    Minute(modifier::Minute),
34    /// AM/PM part of the time.
35    Period(modifier::Period),
36    /// Second within the minute.
37    Second(modifier::Second),
38    /// Subsecond within the second.
39    Subsecond(modifier::Subsecond),
40    /// Hour of the UTC offset.
41    OffsetHour(modifier::OffsetHour),
42    /// Minute within the hour of the UTC offset.
43    OffsetMinute(modifier::OffsetMinute),
44    /// Second within the minute of the UTC offset.
45    OffsetSecond(modifier::OffsetSecond),
46    /// A number of bytes to ignore when parsing. This has no effect on formatting.
47    Ignore(modifier::Ignore),
48    /// A Unix timestamp.
49    UnixTimestamp(modifier::UnixTimestamp),
50    /// The end of input. Parsing this component will fail if there is any input remaining. This
51    /// component neither affects formatting nor consumes any input when parsing.
52    End(modifier::End),
53}