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

zbraniecki / icu4x / 12020603084

23 Nov 2024 08:43PM UTC coverage: 75.71% (+0.2%) from 75.477%
12020603084

push

github

sffc
Touch Cargo.lock

55589 of 73424 relevant lines covered (75.71%)

644270.14 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
pub use formatter::DateTimePatternFormatter;
19
pub use formatter::FormattedDateTimePattern;
20
use icu_pattern::SinglePlaceholderPattern;
21
pub(crate) use names::RawDateTimeNames;
22
pub(crate) use names::RawDateTimeNamesBorrowed;
23
pub(crate) use names::TimeZoneDataPayloadsBorrowed;
24
pub use names::TypedDateTimeNames;
25
pub use pattern::DateTimePattern;
26

27
use crate::fields::Field;
28

29
pub(crate) enum GetNameForMonthError {
30
    Invalid,
31
    NotLoaded,
32
}
33
pub(crate) enum GetNameForWeekdayError {
34
    NotLoaded,
35
}
36

37
pub(crate) enum GetSymbolForEraError {
38
    Invalid,
39
    NotLoaded,
40
}
41

42
pub(crate) enum GetSymbolForCyclicYearError {
43
    Invalid { max: usize },
44
    NotLoaded,
45
}
46

47
pub(crate) enum GetNameForDayPeriodError {
48
    NotLoaded,
49
}
50

51
/// Internal enum to represent the kinds of month symbols for interpolation
52
pub(crate) enum MonthPlaceholderValue<'a> {
53
    PlainString(&'a str),
686✔
54
    Numeric,
55
    NumericPattern(&'a SinglePlaceholderPattern),
56
}
57

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