Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Misc cleanup done for #488 #1059

Merged
merged 5 commits into from
Sep 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions components/datetime/src/pattern/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ impl<'p> Parser<'p> {

pub fn parse_placeholders(
mut self,
mut replacements: Vec<Pattern>,
replacements: Vec<Pattern>,
) -> Result<Vec<PatternItem>, Error> {
let mut chars = self.source.chars().peekable();
let mut result = vec![];
Expand All @@ -157,7 +157,7 @@ impl<'p> Parser<'p> {
let ch = chars.next().ok_or(Error::UnclosedPlaceholder)?;
let idx: u32 = ch.to_digit(10).ok_or(Error::UnknownSubstitution(ch))?;
let replacement = replacements
.get_mut(idx as usize)
.get(idx as usize)
.ok_or(Error::UnknownSubstitution(ch))?;
result.extend_from_slice(replacement.items());
let ch = chars.next().ok_or(Error::UnclosedPlaceholder)?;
Expand Down
4 changes: 2 additions & 2 deletions components/datetime/tests/datetime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -358,8 +358,8 @@ fn test_components_width_differences() {
/// Tests that component::Bags can combine a date skeleton, and a time skeleton.
#[test]
fn test_components_combine_datetime() {
// components/datetime/tests/fixtures/tests/components-combine-date-time.json
test_fixture("components-combine-date-time");
// components/datetime/tests/fixtures/tests/components-combine-datetime.json
test_fixture("components-combine-datetime");
}

#[test]
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
}
},
"output": {
"value": "Tue, Jan 7, 2020 at 8:25 AM"
"value": "Tuesday, January 7, 2020 at 8:25 AM"
}
}
]
31 changes: 30 additions & 1 deletion provider/cldr/src/transform/dates/patterns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ impl From<&cldr_json::Dates> for gregory::DatePatternsV1 {
time_h11_h12,
time_h23_h24,
preferred_hour_cycle,
datetime: (&other.calendars.gregorian.datetime_formats).into(),
datetime: date_time_formats_v1,
}
}
}
Expand Down Expand Up @@ -327,3 +327,32 @@ fn test_with_numbering_system() {
// TODO(#308): Support numbering system variations. We currently throw them away.
assert_eq!("d/M/yy", cs_dates.get().date.short);
}

#[test]
fn test_datetime_skeletons() {
use gregory::patterns::{PatternV1, SkeletonV1};
use icu_locid_macros::langid;

let cldr_paths = crate::cldr_paths::for_test();
let provider = DatePatternsProvider::try_from(&cldr_paths as &dyn CldrPaths).unwrap();

let cs_dates: DataPayload<gregory::DatePatternsV1Marker> = provider
.load_payload(&DataRequest {
resource_path: ResourcePath {
key: key::GREGORY_DATE_PATTERNS_V1,
options: ResourceOptions {
variant: None,
langid: Some(langid!("haw")),
},
},
})
.unwrap()
.take_payload()
.unwrap();
let skeletons = &cs_dates.get().datetime.skeletons.0;

assert_eq!(
Some(&PatternV1::try_from("L").expect("Failed to create pattern")),
skeletons.get(&SkeletonV1::try_from("M").expect("Failed to create Skeleton"))
);
}