Skip to content

Commit

Permalink
Update call sites
Browse files Browse the repository at this point in the history
  • Loading branch information
sffc committed Oct 18, 2024
1 parent 8b4e81b commit c102243
Show file tree
Hide file tree
Showing 20 changed files with 139 additions and 126 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@ icu = "1.5.0"

```rust
use icu::calendar::DateTime;
use icu::datetime::{DateTimeFormatter, NeoSkeletonLength, fieldset::NeoAutoDateTimeMarker};
use icu::datetime::{DateTimeFormatter, NeoSkeletonLength, fieldset::YMDHMS};
use icu::locale::locale;

let dtf = DateTimeFormatter::try_new(
&locale!("es").into(),
NeoAutoDateTimeMarker::with_length(NeoSkeletonLength::Long)
YMDHMS::with_length(NeoSkeletonLength::Long)
)
.expect("locale should be present in compiled data");

Expand Down
6 changes: 3 additions & 3 deletions components/datetime/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions components/datetime/examples/work_log.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use icu_benchmark_macros::println;

use icu_calendar::{DateTime, Gregorian};
use icu_datetime::{
fieldset::NeoYearMonthDayHourMinuteMarker, neo_skeleton::NeoSkeletonLength,
fieldset::YMDHM, neo_skeleton::NeoSkeletonLength,
FixedCalendarDateTimeFormatter,
};
use icu_locale_core::locale;
Expand All @@ -32,7 +32,7 @@ const DATES_ISO: &[(i32, u8, u8, u8, u8, u8)] = &[
fn main() {
let dtf = FixedCalendarDateTimeFormatter::<Gregorian, _>::try_new(
&locale!("en").into(),
NeoYearMonthDayHourMinuteMarker::with_length(NeoSkeletonLength::Medium),
YMDHM::with_length(NeoSkeletonLength::Medium),
)
.expect("Failed to create FixedCalendarDateTimeFormatter instance.");

Expand Down
35 changes: 24 additions & 11 deletions components/datetime/src/fieldset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ macro_rules! impl_marker_with_options {
/// Internal helper macro used by [`impl_date_marker`] and [`impl_calendar_period_marker`]
macro_rules! impl_date_or_calendar_period_marker {
(
$(#[$attr:meta])*
// The name of the type being created.
$type:ident,
// A plain language description of the field set for documentation.
Expand Down Expand Up @@ -218,6 +219,7 @@ macro_rules! impl_date_or_calendar_period_marker {
#[doc = concat!(" \"", $sample, "\"")]
/// );
/// ```
$(#[$attr])*
$type,
sample_length: $sample_length,
$(alignment: $option_alignment_yes,)?
Expand Down Expand Up @@ -278,6 +280,7 @@ macro_rules! impl_date_or_calendar_period_marker {
/// See [`impl_date_marker`].
macro_rules! impl_date_marker {
(
$(#[$attr:meta])*
$type:ident,
$components:expr,
description = $description:literal,
Expand All @@ -296,6 +299,7 @@ macro_rules! impl_date_marker {
$(option_alignment = $option_alignment_yes:ident,)?
) => {
impl_date_or_calendar_period_marker!(
$(#[$attr])*
$type,
description = $description,
sample_length = $sample_length,
Expand Down Expand Up @@ -330,6 +334,7 @@ macro_rules! impl_date_marker {
/// See [`impl_date_marker`].
macro_rules! impl_calendar_period_marker {
(
$(#[$attr:meta])*
$type:ident,
$components:expr,
description = $description:literal,
Expand All @@ -344,6 +349,7 @@ macro_rules! impl_calendar_period_marker {
$(option_alignment = $option_alignment_yes:ident,)?
) => {
impl_date_or_calendar_period_marker!(
$(#[$attr])*
$type,
description = $description,
sample_length = $sample_length,
Expand Down Expand Up @@ -371,6 +377,7 @@ macro_rules! impl_calendar_period_marker {
/// Documentation for each option is shown inline below.
macro_rules! impl_time_marker {
(
$(#[$attr:meta])*
// The name of the type being created.
$type:ident,
// An expression for the field set.
Expand Down Expand Up @@ -443,6 +450,7 @@ macro_rules! impl_time_marker {
#[doc = concat!(" \"", $sample, "\"")]
/// );
/// ```
$(#[$attr])*
$type,
sample_length: $sample_length,
alignment: yes,
Expand Down Expand Up @@ -783,11 +791,13 @@ macro_rules! impl_zoneddatetime_marker {
}

impl_date_marker!(
/// This format may use ordinal formatting, such as "the 17th",
/// in the future. See CLDR-18040.
D,
NeoDateComponents::Day,
description = "day of month (standalone)",
sample_length = Short,
sample = "the 17th",
sample = "17",
input_day_of_month = yes,
input_any_calendar_kind = yes,
option_alignment = yes,
Expand All @@ -804,11 +814,13 @@ impl_date_marker!(
);

impl_date_marker!(
/// This format may use ordinal formatting, such as "Friday the 17th",
/// in the future. See CLDR-18040.
DE,
NeoDateComponents::DayWeekday,
description = "day of month and weekday",
sample_length = Long,
sample = "Friday the 17th",
sample = "17 Friday",
weekdays = yes,
input_day_of_month = yes,
input_day_of_week = yes,
Expand All @@ -829,11 +841,12 @@ impl_date_marker!(
);

impl_date_marker!(
/// See CLDR-18040 for progress on improving this format.
MDE,
NeoDateComponents::MonthDayWeekday,
description = "month, day, and weekday",
sample_length = Medium,
sample = "Friday, May 17",
sample = "Fri, May 17",
months = yes,
weekdays = yes,
input_month = yes,
Expand Down Expand Up @@ -1041,8 +1054,8 @@ impl_zone_marker!(
/// use icu::timezone::{TimeZoneInfo, CustomZonedDateTime};
/// use icu::calendar::Gregorian;
/// use icu::datetime::DateTimeFormatter;
/// use icu::datetime::fieldset::NeoMonthDayMarker;
/// use icu::datetime::fieldset::NeoHourMinuteMarker;
/// use icu::datetime::fieldset::MD;
/// use icu::datetime::fieldset::HM;
/// use icu::datetime::fieldset::NeoTimeZoneSpecificShortMarker;
/// use icu::datetime::DateTimeCombo;
/// use icu::datetime::neo_skeleton::NeoSkeletonLength;
Expand All @@ -1051,8 +1064,8 @@ impl_zone_marker!(
/// use writeable::assert_try_writeable_eq;
///
/// type MyDateTimeZoneSet = DateTimeCombo<
/// NeoMonthDayMarker,
/// NeoHourMinuteMarker,
/// MD,
/// HM,
/// NeoTimeZoneSpecificShortMarker,
/// >;
///
Expand Down Expand Up @@ -1313,8 +1326,8 @@ impl_zone_marker!(
/// use icu::timezone::{TimeZoneInfo, CustomZonedDateTime};
/// use icu::calendar::Gregorian;
/// use icu::datetime::DateTimeFormatter;
/// use icu::datetime::fieldset::NeoMonthDayMarker;
/// use icu::datetime::fieldset::NeoHourMinuteMarker;
/// use icu::datetime::fieldset::MD;
/// use icu::datetime::fieldset::HM;
/// use icu::datetime::fieldset::NeoTimeZoneGenericShortMarker;
/// use icu::datetime::DateTimeCombo;
/// use icu::datetime::neo_skeleton::NeoSkeletonLength;
Expand All @@ -1323,8 +1336,8 @@ impl_zone_marker!(
/// use writeable::assert_try_writeable_eq;
///
/// type MyDateTimeZoneSet = DateTimeCombo<
/// NeoMonthDayMarker,
/// NeoHourMinuteMarker,
/// MD,
/// HM,
/// NeoTimeZoneGenericShortMarker,
/// >;
///
Expand Down
4 changes: 2 additions & 2 deletions components/datetime/src/format/datetime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,7 @@ where
#[cfg(feature = "compiled_data")]
mod tests {
use super::*;
use crate::{fieldset::NeoAutoDateMarker, neo_skeleton::NeoSkeletonLength, pattern::runtime};
use crate::{fieldset::YMD, neo_skeleton::NeoSkeletonLength, pattern::runtime};
use icu_decimal::options::{FixedDecimalFormatterOptions, GroupingStrategy};
use tinystr::tinystr;

Expand All @@ -570,7 +570,7 @@ mod tests {
let locale = icu::locale::locale!("en-u-ca-japanese");
let dtf = DateTimeFormatter::try_new(
&locale.into(),
NeoAutoDateMarker::with_length(NeoSkeletonLength::Medium),
YMD::with_length(NeoSkeletonLength::Medium),
)
.expect("DateTimeFormat construction succeeds");

Expand Down
6 changes: 3 additions & 3 deletions components/datetime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
//! ```
//! use icu::calendar::{DateTime, Gregorian};
//! use icu::datetime::{DateTimeFormatter, FixedCalendarDateTimeFormatter};
//! use icu::datetime::fieldset::NeoYearMonthDayHourMinuteMarker;
//! use icu::datetime::fieldset::YMDHM;
//! use icu::datetime::neo_skeleton::NeoSkeletonLength;
//! use icu::locale::{locale, Locale};
//! use writeable::assert_try_writeable_eq;
Expand All @@ -38,14 +38,14 @@
//! let locale = Locale::try_from_str("en-u-ca-gregory").unwrap();
//! let dtf = DateTimeFormatter::try_new(
//! &locale.into(),
//! NeoYearMonthDayHourMinuteMarker::with_length(NeoSkeletonLength::Medium),
//! YMDHM::with_length(NeoSkeletonLength::Medium),
//! )
//! .expect("should successfully create DateTimeFormatter instance");
//!
//! // Or one that selects a calendar at compile time:
//! let typed_dtf = FixedCalendarDateTimeFormatter::<Gregorian, _>::try_new(
//! &locale!("en").into(),
//! NeoYearMonthDayHourMinuteMarker::with_length(NeoSkeletonLength::Medium),
//! YMDHM::with_length(NeoSkeletonLength::Medium),
//! )
//! .expect("should successfully create FixedCalendarDateTimeFormatter instance");
//!
Expand Down
Loading

0 comments on commit c102243

Please sign in to comment.