Skip to main content

ferroui_base/utilities/
date_time_styles.rs

1//! Options of date and time parsing (.NET `System.Globalization.DateTimeStyles`).
2
3use bitflags::bitflags;
4
5bitflags! {
6    /// Options that customise how a date and time string is parsed.
7    #[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
8    pub struct DateTimeStyles: u32 {
9        /// Leading white space is allowed (always allowed by `parse`).
10        const ALLOW_LEADING_WHITE = 0x01;
11        /// Trailing white space is allowed (always allowed by `parse`).
12        const ALLOW_TRAILING_WHITE = 0x02;
13        /// Extra white space inside the string is allowed.
14        const ALLOW_INNER_WHITE = 0x04;
15        /// Leading, trailing and inner white space is allowed.
16        const ALLOW_WHITE_SPACES = 0x07;
17        /// A string with a time but no date gives the date 0001-01-01
18        /// instead of the current date.
19        const NO_CURRENT_DATE_DEFAULT = 0x08;
20        /// The result is converted to UTC.
21        const ADJUST_TO_UNIVERSAL = 0x10;
22        /// A string without time zone information is taken as local time.
23        const ASSUME_LOCAL = 0x20;
24        /// A string without time zone information is taken as UTC.
25        const ASSUME_UNIVERSAL = 0x40;
26        /// The kind stated by the string (`Z` or an offset) is preserved.
27        const ROUNDTRIP_KIND = 0x80;
28    }
29}
30
31impl DateTimeStyles {
32    /// The default options (.NET `DateTimeStyles.None`).
33    pub const NONE: DateTimeStyles = DateTimeStyles::empty();
34}