• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

zbraniecki / icu4x / 13958601093

19 Mar 2025 04:17PM UTC coverage: 74.164% (-1.5%) from 75.71%
13958601093

push

github

web-flow
Clean up properties docs (#6315)

58056 of 78281 relevant lines covered (74.16%)

819371.32 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

14.29
/components/datetime/src/pattern/mod.rs
1
// This file is part of ICU4X. For terms of use, please see the file
2
// called LICENSE at the top level of the ICU4X source tree
3
// (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ).
4

5
//! Lower-level, power-user APIs for formatting datetimes with pattern strings.
6
//!
7
//! ❗ This module forgoes most internationalization functionality of the datetime crate.
8
//! It assumes that the pattern is already localized for the customer's locale. Most clients
9
//! should use [`DateTimeFormatter`] instead of directly formatting with patterns.
10
//!
11
//! [`DateTimeFormatter`]: crate::DateTimeFormatter
12

13
mod formatter;
14
mod names;
15
#[allow(clippy::module_inception)] // the file pattern.rs should contain DateTimePattern
16
mod pattern;
17

18
use crate::error::ErrorField;
19
pub use formatter::DateTimePatternFormatter;
20
pub use formatter::FormattedDateTimePattern;
21
use icu_pattern::SinglePlaceholderPattern;
22
pub use names::DateTimeNames;
23
pub use names::DayPeriodNameLength;
24
pub use names::FixedCalendarDateTimeNames;
25
pub use names::MonthNameLength;
26
pub(crate) use names::RawDateTimeNames;
27
pub(crate) use names::RawDateTimeNamesBorrowed;
28
pub(crate) use names::TimeZoneDataPayloadsBorrowed;
29
pub use names::WeekdayNameLength;
30
pub use names::YearNameLength;
31
pub use pattern::DateTimePattern;
32

33
pub(crate) enum GetNameForMonthError {
34
    InvalidMonthCode,
35
    InvalidFieldLength,
36
    NotLoaded,
37
}
38
pub(crate) enum GetNameForWeekdayError {
39
    InvalidFieldLength,
40
    NotLoaded,
41
}
42

43
pub(crate) enum GetNameForEraError {
44
    InvalidEraCode,
45
    InvalidFieldLength,
46
    NotLoaded,
47
}
48

49
pub(crate) enum GetNameForCyclicYearError {
50
    InvalidYearNumber { max: usize },
51
    InvalidFieldLength,
52
    NotLoaded,
53
}
54

55
pub(crate) enum GetNameForDayPeriodError {
56
    InvalidFieldLength,
57
    NotLoaded,
58
}
59

60
/// Internal enum to represent the kinds of month symbols for interpolation
61
pub(crate) enum MonthPlaceholderValue<'a> {
62
    PlainString(&'a str),
710✔
63
    Numeric,
64
    NumericPattern(&'a SinglePlaceholderPattern),
65
}
66

67
/// Error returned from [`FixedCalendarDateTimeNames`]'s pattern load methods.
68
#[derive(Debug, Clone, Copy, PartialEq, displaydoc::Display)]
×
69
#[non_exhaustive]
70
pub enum PatternLoadError {
71
    /// A field conflicts with a previous field.
72
    ///
73
    /// Fields conflict if they require the same type of data, for example the
74
    /// `EEE` and `EEEE` fields (short vs long weekday) conflict, or the `M`
75
    /// and `L` (format vs standalone month) conflict.
76
    #[displaydoc("A field {0:?} conflicts with a previous field.")]
77
    ConflictingField(ErrorField),
×
78
    /// The field symbol is not supported in that length.
79
    ///
80
    /// Some fields, such as `O` are not defined for all lengths (e.g. `OO`).
81
    #[displaydoc("The field {0:?} symbol is not supported in that length.")]
82
    UnsupportedLength(ErrorField),
×
83
    /// The specific formatter does not support this field.
84
    ///
85
    /// This happens for example when trying to load a month field
86
    /// on a [`FixedCalendarDateTimeNames<Gregorian, ZoneFieldSet>`].
87
    #[displaydoc("The specific formatter does not support the field {0:?}.")]
88
    FormatterTooSpecific(ErrorField),
×
89
    /// An error arising from the [`data provider`](icu_provider) for loading names.
90
    #[displaydoc("Problem loading data for field {1:?}: {0}")]
×
91
    Data(icu_provider::DataError, ErrorField),
×
92
}
93

94
impl core::error::Error for PatternLoadError {}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc