mirror of
https://github.com/storytold/deckcraft.git
synced 2026-10-31 07:38:16 +00:00
[HH5] Long English dates follow each English locale's day order and punctuation
PowerPoint formats the datetime types by the run's language: en-GB's long
date is "18 October 2026" and the weekday form "Sunday, 18 October 2026".
We gave every English locale the US order ("October 18, 2026"), and a test
pinned that. datetime2 and datetime4 now put the day first for en-GB, en-AU,
en-NZ, en-IE and en-IN (the locales the numeric date already handled), and
datetime2 also for en-ZA. The punctuation follows PowerPoint on Windows as
checked per locale in review: en-IE writes no comma after the weekday
("Tuesday 27 October 2026"), and en-GB and en-AU put a comma after the month
in datetime3 ("27 October, 2026"). Other languages still have no month names,
so they are refused as before.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
55e5ee56b4
commit
50b200be7c
2 files changed
+46
-1
No files matched your search
@@ -449,6 +449,17 @@ mod tests {
|
||||
assert_eq!(undo(&s), before + 1);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_long_british_date_puts_the_day_first() {
|
||||
let mut s = session();
|
||||
edit_title(&mut s);
|
||||
let v = s.execute("insert.dateTime", &json!({"format": "datetime4", "update": false, "language": "en-GB"})).unwrap();
|
||||
let text = v["text"].as_str().unwrap().to_string();
|
||||
assert!(text.chars().next().is_some_and(|c| c.is_ascii_digit()) && !text.contains(','), "{text}");
|
||||
let v = s.execute("insert.dateTime", &json!({"format": "datetime4", "update": false, "language": "en-US"})).unwrap();
|
||||
assert!(v["text"].as_str().is_some_and(|t| t.contains(',')), "{v}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_named_format_in_french_and_a_bad_value_change_nothing() {
|
||||
let mut s = session();
|
||||
|
||||
@@ -104,11 +104,20 @@ pub fn field_text(kind: &str, lang: Option<&str>, now: DateTime) -> Option<Strin
|
||||
let ampm = if now.hour < 12 { "AM" } else { "PM" };
|
||||
let (mi, s) = (now.minute, now.second);
|
||||
let short = short_date(&lang, now);
|
||||
// British-style English writes the day before the month ("9 October 2026"). The punctuation
|
||||
// follows PowerPoint on Windows per locale: Irish English has no comma after the weekday,
|
||||
// British and Australian English put one after the month in `datetime3`, and South African
|
||||
// English writes the weekday form day first too.
|
||||
let day_first = matches!(lang.as_str(), "en-gb" | "en-au" | "en-nz" | "en-ie" | "en-in");
|
||||
let named = |text: String| english.then_some(text);
|
||||
match kind {
|
||||
"datetime" | "datetimeFigureOut" | "datetime1" => Some(short),
|
||||
"datetime2" if lang == "en-ie" => named(format!("{day} {d} {month} {y}")),
|
||||
"datetime2" if day_first || lang == "en-za" => named(format!("{day}, {d} {month} {y}")),
|
||||
"datetime2" => named(format!("{day}, {month} {d}, {y}")),
|
||||
"datetime3" if matches!(lang.as_str(), "en-gb" | "en-au") => named(format!("{d} {month}, {y}")),
|
||||
"datetime3" => named(format!("{d} {month} {y}")),
|
||||
"datetime4" if day_first => named(format!("{d} {month} {y}")),
|
||||
"datetime4" => named(format!("{month} {d}, {y}")),
|
||||
"datetime5" => named(format!("{d}-{mon}-{yy:02}")),
|
||||
"datetime6" => named(format!("{month} {yy:02}")),
|
||||
@@ -183,7 +192,32 @@ mod tests {
|
||||
// Month names in another language: not computed (the field keeps its saved text).
|
||||
assert_eq!(field_text("datetime2", Some("de-DE"), FRI), None);
|
||||
assert_eq!(field_text("datetime12", Some("fr-FR"), FRI), None);
|
||||
assert_eq!(field_text("datetime4", Some("en-GB"), FRI).as_deref(), Some("October 9, 2026"));
|
||||
assert_eq!(field_text("datetime4", Some("en-GB"), FRI).as_deref(), Some("9 October 2026"));
|
||||
assert_eq!(field_text("datetime2", Some("en-GB"), FRI).as_deref(), Some("Friday, 9 October 2026"));
|
||||
assert_eq!(field_text("datetime4", Some("en-AU"), FRI).as_deref(), Some("9 October 2026"));
|
||||
assert_eq!(field_text("datetime4", Some("en-US"), FRI).as_deref(), Some("October 9, 2026"));
|
||||
}
|
||||
|
||||
/// The long English dates as PowerPoint on Windows shows them on Tuesday 27 October 2026, read
|
||||
/// per run language (datetime2, datetime3, datetime4).
|
||||
#[test]
|
||||
fn long_english_dates_follow_each_locale() {
|
||||
let tue = DateTime::new(2026, 10, 27, 9, 0, 0);
|
||||
let rows = [
|
||||
("en-US", "Tuesday, October 27, 2026", "27 October 2026", "October 27, 2026"),
|
||||
("en-GB", "Tuesday, 27 October 2026", "27 October, 2026", "27 October 2026"),
|
||||
("en-AU", "Tuesday, 27 October 2026", "27 October, 2026", "27 October 2026"),
|
||||
("en-NZ", "Tuesday, 27 October 2026", "27 October 2026", "27 October 2026"),
|
||||
("en-IE", "Tuesday 27 October 2026", "27 October 2026", "27 October 2026"),
|
||||
("en-IN", "Tuesday, 27 October 2026", "27 October 2026", "27 October 2026"),
|
||||
("en-CA", "Tuesday, October 27, 2026", "27 October 2026", "October 27, 2026"),
|
||||
];
|
||||
for (lang, d2, d3, d4) in rows {
|
||||
assert_eq!(field_text("datetime2", Some(lang), tue).as_deref(), Some(d2), "{lang}");
|
||||
assert_eq!(field_text("datetime3", Some(lang), tue).as_deref(), Some(d3), "{lang}");
|
||||
assert_eq!(field_text("datetime4", Some(lang), tue).as_deref(), Some(d4), "{lang}");
|
||||
}
|
||||
assert_eq!(field_text("datetime2", Some("en-ZA"), tue).as_deref(), Some("Tuesday, 27 October 2026"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
Reference in new issue
Block a user