BlueGit

ict rusty-teams

fix(format): date labels follow the regional format and app language

Schedule send, agenda, reactions, status expiry, call notices, find in
chat, agent sessions, meeting proposals, the calendar peek and Share to
Outlook formatted with chrono's English %a/%b or fixed patterns. They
now use the regional patterns, and weekday and month names from the
locale catalog. Sizes and call health use the regional decimal
separator.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

metis Michael Wallner · pushed by metis

Authored 2026-11-16 · 2 weeks ago

Hash
c3cc55b24a16787fd555d656503abbd592f8a655
Parent
8fcccadf
12 files changed +91 −91
crates/app-base/src/schedule_time.rs +13 −9
@@ -131,7 +131,7 @@ pub fn day_choices(today: NaiveDate) -> Vec<DayChoice> {
131 131 let date = today + Duration::days(offset);
132 132 DayChoice {
133 133 date,
134 label: date.format("%a %-d %b").to_string(),
134 label: crate::format::weekday_date_label(date),
135 135 }
136 136 })
137 137 .collect()
@@ -174,13 +174,13 @@ pub fn format_time(time: NaiveTime) -> String {
174 174
175 175 pub fn describe(at: DateTime<Local>, now: DateTime<Local>) -> String {
176 176 let days_ahead = (at.date_naive() - now.date_naive()).num_days();
177 let clock = at.format(crate::format::clock_format()).to_string();
177 178 match days_ahead {
178 0 => format!("today {}", at.format(crate::format::clock_format())),
179 0 => crate::ui_locale::tr_with("regional.today_clock", &[("clock", &clock)]),
179 180 1..=6 => weekday_clock(at),
180 181 _ => format!(
181 "{} {}",
182 at.format("%a %-d %b"),
183 at.format(crate::format::clock_format())
182 "{} {clock}",
183 crate::format::weekday_date_label(at.date_naive())
184 184 ),
185 185 }
186 186 }
@@ -188,7 +188,7 @@ pub fn describe(at: DateTime<Local>, now: DateTime<Local>) -> String {
188 188 fn weekday_clock(at: DateTime<Local>) -> String {
189 189 format!(
190 190 "{} {}",
191 at.format("%a"),
191 crate::format::weekday_name(at.weekday(), crate::format::WeekdayWidth::Short),
192 192 at.format(crate::format::clock_format())
193 193 )
194 194 }
@@ -226,6 +226,7 @@ mod tests {
226 226
227 227 #[test]
228 228 fn midweek_offers_tomorrow_and_next_monday() {
229 let _guard = crate::ui_locale::locale_test_lock();
229 230 let found = presets(at(8, 9, 0));
230 231 let labels: Vec<_> = found.iter().map(|preset| preset.label).collect();
231 232 assert_eq!(
@@ -250,6 +251,7 @@ mod tests {
250 251
251 252 #[test]
252 253 fn sunday_shows_tomorrow_only_because_monday_would_duplicate_it() {
254 let _guard = crate::ui_locale::locale_test_lock();
253 255 let found = presets(at(11, 21, 0));
254 256 assert_eq!(found.len(), 1);
255 257 assert_eq!(found[0].kind, PresetKind::TomorrowMorning);
@@ -285,10 +287,11 @@ mod tests {
285 287
286 288 #[test]
287 289 fn day_choices_run_from_today_for_seven_days() {
290 let _guard = crate::ui_locale::locale_test_lock();
288 291 let choices = day_choices(at(9, 12, 0).date_naive());
289 292 assert_eq!(choices.len(), 7);
290 assert_eq!(choices[0].label, "Fri 9 Oct");
291 assert_eq!(choices[6].label, "Thu 15 Oct");
293 assert_eq!(choices[0].label, "Fri, Oct 9");
294 assert_eq!(choices[6].label, "Thu, Oct 15");
292 295 }
293 296
294 297 #[test]
@@ -318,9 +321,10 @@ mod tests {
318 321
319 322 #[test]
320 323 fn describing_a_time_names_today_or_the_weekday() {
324 let _guard = crate::ui_locale::locale_test_lock();
321 325 let now = at(9, 10, 0);
322 326 assert_eq!(describe(at(9, 15, 30), now), "today 15:30");
323 327 assert_eq!(describe(at(12, 8, 15), now), "Mon 08:15");
324 assert_eq!(describe(at(16, 8, 15), now), "Fri 16 Oct 08:15");
328 assert_eq!(describe(at(16, 8, 15), now), "Fri, Oct 16 08:15");
325 329 }
326 330 }
@@ -131,7 +131,7 @@ pub fn day_choices(today: NaiveDate) -> Vec<DayChoice> {
131 let date = today + Duration::days(offset);
131 let date = today + Duration::days(offset);
132 DayChoice {
132 DayChoice {
133 date,
133 date,
134 label: date.format("%a %-d %b").to_string(),
134 label: crate::format::weekday_date_label(date),
135 }
135 }
136 })
136 })
137 .collect()
137 .collect()
@@ -174,13 +174,13 @@ pub fn format_time(time: NaiveTime) -> String {
174
174
175pub fn describe(at: DateTime<Local>, now: DateTime<Local>) -> String {
175pub fn describe(at: DateTime<Local>, now: DateTime<Local>) -> String {
176 let days_ahead = (at.date_naive() - now.date_naive()).num_days();
176 let days_ahead = (at.date_naive() - now.date_naive()).num_days();
177 let clock = at.format(crate::format::clock_format()).to_string();
177 match days_ahead {
178 match days_ahead {
178 0 => format!("today {}", at.format(crate::format::clock_format())),
179 0 => crate::ui_locale::tr_with("regional.today_clock", &[("clock", &clock)]),
179 1..=6 => weekday_clock(at),
180 1..=6 => weekday_clock(at),
180 _ => format!(
181 _ => format!(
181 "{} {}",
182 "{} {clock}",
182 at.format("%a %-d %b"),
183 crate::format::weekday_date_label(at.date_naive())
183 at.format(crate::format::clock_format())
184 ),
184 ),
185 }
185 }
186}
186}
@@ -188,7 +188,7 @@ pub fn describe(at: DateTime<Local>, now: DateTime<Local>) -> String {
188fn weekday_clock(at: DateTime<Local>) -> String {
188fn weekday_clock(at: DateTime<Local>) -> String {
189 format!(
189 format!(
190 "{} {}",
190 "{} {}",
191 at.format("%a"),
191 crate::format::weekday_name(at.weekday(), crate::format::WeekdayWidth::Short),
192 at.format(crate::format::clock_format())
192 at.format(crate::format::clock_format())
193 )
193 )
194}
194}
@@ -226,6 +226,7 @@ mod tests {
226
226
227 #[test]
227 #[test]
228 fn midweek_offers_tomorrow_and_next_monday() {
228 fn midweek_offers_tomorrow_and_next_monday() {
229 let _guard = crate::ui_locale::locale_test_lock();
229 let found = presets(at(8, 9, 0));
230 let found = presets(at(8, 9, 0));
230 let labels: Vec<_> = found.iter().map(|preset| preset.label).collect();
231 let labels: Vec<_> = found.iter().map(|preset| preset.label).collect();
231 assert_eq!(
232 assert_eq!(
@@ -250,6 +251,7 @@ mod tests {
250
251
251 #[test]
252 #[test]
252 fn sunday_shows_tomorrow_only_because_monday_would_duplicate_it() {
253 fn sunday_shows_tomorrow_only_because_monday_would_duplicate_it() {
254 let _guard = crate::ui_locale::locale_test_lock();
253 let found = presets(at(11, 21, 0));
255 let found = presets(at(11, 21, 0));
254 assert_eq!(found.len(), 1);
256 assert_eq!(found.len(), 1);
255 assert_eq!(found[0].kind, PresetKind::TomorrowMorning);
257 assert_eq!(found[0].kind, PresetKind::TomorrowMorning);
@@ -285,10 +287,11 @@ mod tests {
285
287
286 #[test]
288 #[test]
287 fn day_choices_run_from_today_for_seven_days() {
289 fn day_choices_run_from_today_for_seven_days() {
290 let _guard = crate::ui_locale::locale_test_lock();
288 let choices = day_choices(at(9, 12, 0).date_naive());
291 let choices = day_choices(at(9, 12, 0).date_naive());
289 assert_eq!(choices.len(), 7);
292 assert_eq!(choices.len(), 7);
290 assert_eq!(choices[0].label, "Fri 9 Oct");
293 assert_eq!(choices[0].label, "Fri, Oct 9");
291 assert_eq!(choices[6].label, "Thu 15 Oct");
294 assert_eq!(choices[6].label, "Thu, Oct 15");
292 }
295 }
293
296
294 #[test]
297 #[test]
@@ -318,9 +321,10 @@ mod tests {
318
321
319 #[test]
322 #[test]
320 fn describing_a_time_names_today_or_the_weekday() {
323 fn describing_a_time_names_today_or_the_weekday() {
324 let _guard = crate::ui_locale::locale_test_lock();
321 let now = at(9, 10, 0);
325 let now = at(9, 10, 0);
322 assert_eq!(describe(at(9, 15, 30), now), "today 15:30");
326 assert_eq!(describe(at(9, 15, 30), now), "today 15:30");
323 assert_eq!(describe(at(12, 8, 15), now), "Mon 08:15");
327 assert_eq!(describe(at(12, 8, 15), now), "Mon 08:15");
324 assert_eq!(describe(at(16, 8, 15), now), "Fri 16 Oct 08:15");
328 assert_eq!(describe(at(16, 8, 15), now), "Fri, Oct 16 08:15");
325 }
329 }
326}
330}
crates/app-base/src/support.rs +8 −2
@@ -277,9 +277,15 @@ pub fn format_bytes(size: u64) -> String {
277 277 const KB: u64 = 1024;
278 278 const MB: u64 = KB * 1024;
279 279 if size >= MB {
280 format!("{:.1} MB", size as f64 / MB as f64)
280 format!(
281 "{} MB",
282 crate::format::decimal_label(size as f64 / MB as f64, 1)
283 )
281 284 } else if size >= KB {
282 format!("{:.1} KB", size as f64 / KB as f64)
285 format!(
286 "{} KB",
287 crate::format::decimal_label(size as f64 / KB as f64, 1)
288 )
283 289 } else {
284 290 format!("{size} B")
285 291 }
@@ -277,9 +277,15 @@ pub fn format_bytes(size: u64) -> String {
277 const KB: u64 = 1024;
277 const KB: u64 = 1024;
278 const MB: u64 = KB * 1024;
278 const MB: u64 = KB * 1024;
279 if size >= MB {
279 if size >= MB {
280 format!("{:.1} MB", size as f64 / MB as f64)
280 format!(
281 "{} MB",
282 crate::format::decimal_label(size as f64 / MB as f64, 1)
283 )
281 } else if size >= KB {
284 } else if size >= KB {
282 format!("{:.1} KB", size as f64 / KB as f64)
285 format!(
286 "{} KB",
287 crate::format::decimal_label(size as f64 / KB as f64, 1)
288 )
283 } else {
289 } else {
284 format!("{size} B")
290 format!("{size} B")
285 }
291 }
crates/app-call-model/src/agenda.rs +3 −3
@@ -59,11 +59,11 @@ pub fn response_label(response: ResponseType) -> &'static str {
59 59
60 60 pub fn day_heading(day: NaiveDate, today: NaiveDate) -> String {
61 61 if day == today {
62 "Today".to_owned()
62 app_base::ui_locale::tr("regional.today")
63 63 } else if today.succ_opt() == Some(day) {
64 "Tomorrow".to_owned()
64 app_base::ui_locale::tr("regional.tomorrow")
65 65 } else {
66 day.format("%a, %b %-d").to_string()
66 app_base::format::weekday_date_label(day)
67 67 }
68 68 }
69 69
@@ -59,11 +59,11 @@ pub fn response_label(response: ResponseType) -> &'static str {
59
59
60pub fn day_heading(day: NaiveDate, today: NaiveDate) -> String {
60pub fn day_heading(day: NaiveDate, today: NaiveDate) -> String {
61 if day == today {
61 if day == today {
62 "Today".to_owned()
62 app_base::ui_locale::tr("regional.today")
63 } else if today.succ_opt() == Some(day) {
63 } else if today.succ_opt() == Some(day) {
64 "Tomorrow".to_owned()
64 app_base::ui_locale::tr("regional.tomorrow")
65 } else {
65 } else {
66 day.format("%a, %b %-d").to_string()
66 app_base::format::weekday_date_label(day)
67 }
67 }
68}
68}
69
69
crates/app-call-model/src/health.rs +11 −2
@@ -71,7 +71,10 @@ pub fn level_text(level: NetworkLevel) -> &'static str {
71 71
72 72 fn rate_text(kilobits_per_second: f64) -> String {
73 73 if kilobits_per_second >= 1000. {
74 format!("{:.1} Mbps", kilobits_per_second / 1000.)
74 format!(
75 "{} Mbps",
76 app_base::format::decimal_label(kilobits_per_second / 1000., 1)
77 )
75 78 } else {
76 79 format!("{kilobits_per_second:.0} kbps")
77 80 }
@@ -79,7 +82,13 @@ fn rate_text(kilobits_per_second: f64) -> String {
79 82
80 83 pub fn network_rows(sample: &HealthSample) -> Vec<(&'static str, String)> {
81 84 vec![
82 ("Packet loss", format!("{:.1}%", sample.loss_percent)),
85 (
86 "Packet loss",
87 format!(
88 "{}%",
89 app_base::format::decimal_label(sample.loss_percent, 1)
90 ),
91 ),
83 92 ("Round trip", format!("{:.0} ms", sample.round_trip_ms)),
84 93 ("Jitter", format!("{:.0} ms", sample.jitter_ms)),
85 94 ("Sent", rate_text(sample.sent_kbps)),
@@ -71,7 +71,10 @@ pub fn level_text(level: NetworkLevel) -> &'static str {
71
71
72fn rate_text(kilobits_per_second: f64) -> String {
72fn rate_text(kilobits_per_second: f64) -> String {
73 if kilobits_per_second >= 1000. {
73 if kilobits_per_second >= 1000. {
74 format!("{:.1} Mbps", kilobits_per_second / 1000.)
74 format!(
75 "{} Mbps",
76 app_base::format::decimal_label(kilobits_per_second / 1000., 1)
77 )
75 } else {
78 } else {
76 format!("{kilobits_per_second:.0} kbps")
79 format!("{kilobits_per_second:.0} kbps")
77 }
80 }
@@ -79,7 +82,13 @@ fn rate_text(kilobits_per_second: f64) -> String {
79
82
80pub fn network_rows(sample: &HealthSample) -> Vec<(&'static str, String)> {
83pub fn network_rows(sample: &HealthSample) -> Vec<(&'static str, String)> {
81 vec![
84 vec![
82 ("Packet loss", format!("{:.1}%", sample.loss_percent)),
85 (
86 "Packet loss",
87 format!(
88 "{}%",
89 app_base::format::decimal_label(sample.loss_percent, 1)
90 ),
91 ),
83 ("Round trip", format!("{:.0} ms", sample.round_trip_ms)),
92 ("Round trip", format!("{:.0} ms", sample.round_trip_ms)),
84 ("Jitter", format!("{:.0} ms", sample.jitter_ms)),
93 ("Jitter", format!("{:.0} ms", sample.jitter_ms)),
85 ("Sent", rate_text(sample.sent_kbps)),
94 ("Sent", rate_text(sample.sent_kbps)),
crates/app-state/src/agents/session_options.rs +4 −3
@@ -2,7 +2,7 @@ use std::collections::HashSet;
2 2 use std::path::{Path, PathBuf};
3 3
4 4 use agents::{DesktopSession, Environment, RunningSession};
5 use chrono::{DateTime, Local, Utc};
5 use chrono::{DateTime, Datelike, Local, Utc};
6 6 use mcp::install::{Homes, Location};
7 7
8 8 use super::message_context;
@@ -34,9 +34,10 @@ pub fn relative_age(now: DateTime<Utc>, then: DateTime<Utc>) -> String {
34 34 } else if age.num_days() < 1 {
35 35 format!("{}h", age.num_hours())
36 36 } else if age.num_days() < WEEK_DAYS {
37 then.with_timezone(&Local).format("%a").to_string()
37 let weekday = then.with_timezone(&Local).weekday();
38 crate::format::weekday_name(weekday, crate::format::WeekdayWidth::Short)
38 39 } else {
39 then.with_timezone(&Local).format("%b %-d").to_string()
40 crate::format::day_month_label(then.with_timezone(&Local).date_naive())
40 41 }
41 42 }
42 43
@@ -2,7 +2,7 @@ use std::collections::HashSet;
2use std::path::{Path, PathBuf};
2use std::path::{Path, PathBuf};
3
3
4use agents::{DesktopSession, Environment, RunningSession};
4use agents::{DesktopSession, Environment, RunningSession};
5use chrono::{DateTime, Local, Utc};
5use chrono::{DateTime, Datelike, Local, Utc};
6use mcp::install::{Homes, Location};
6use mcp::install::{Homes, Location};
7
7
8use super::message_context;
8use super::message_context;
@@ -34,9 +34,10 @@ pub fn relative_age(now: DateTime<Utc>, then: DateTime<Utc>) -> String {
34 } else if age.num_days() < 1 {
34 } else if age.num_days() < 1 {
35 format!("{}h", age.num_hours())
35 format!("{}h", age.num_hours())
36 } else if age.num_days() < WEEK_DAYS {
36 } else if age.num_days() < WEEK_DAYS {
37 then.with_timezone(&Local).format("%a").to_string()
37 let weekday = then.with_timezone(&Local).weekday();
38 crate::format::weekday_name(weekday, crate::format::WeekdayWidth::Short)
38 } else {
39 } else {
39 then.with_timezone(&Local).format("%b %-d").to_string()
40 crate::format::day_month_label(then.with_timezone(&Local).date_naive())
40 }
41 }
41}
42}
42
43
crates/app-state/src/call_rows.rs +15 −7
@@ -1,7 +1,7 @@
1 1 use std::collections::{HashMap, HashSet};
2 2
3 3 use app_base::format::Zone;
4 use chrono::{DateTime, NaiveDate, Utc};
4 use chrono::{DateTime, Datelike, FixedOffset, NaiveDate, Utc};
5 5 use store::MessageRecord;
6 6 use teams_core::roster_event::RosterEvent;
7 7 use teams_core::{CallEvent, CallPhase, CallType, ImageRef, format_duration};
@@ -10,7 +10,6 @@ use crate::format;
10 10
11 11 const MAX_AVATARS: usize = 4;
12 12 const RECAP_FALLBACK_TITLE: &str = "Meeting";
13 const RECAP_DATE_FORMAT: &str = "%A, %-d %B %Y";
14 13 const AUTO_STOP_SECONDS: i64 = 5;
15 14 const WEEKDAY_STAMP_DAYS: i64 = 6;
16 15 const OWN_NAME: &str = "You";
@@ -323,10 +322,7 @@ fn recap_date_line(
323 322 });
324 323 format!(
325 324 "{} - {}",
326 clock.offset.at(slot.start).format(&format!(
327 "{RECAP_DATE_FORMAT} {}",
328 app_base::format::clock_format()
329 )),
325 recap_start_label(clock.offset.at(slot.start)),
330 326 clock
331 327 .offset
332 328 .at(slot.end)
@@ -334,6 +330,16 @@ fn recap_date_line(
334 330 )
335 331 }
336 332
333 /// "Thursday, 16. November 2026 14:30" in the app language and regional format.
334 fn recap_start_label(start: DateTime<FixedOffset>) -> String {
335 format!(
336 "{}, {} {}",
337 format::weekday_name(start.weekday(), format::WeekdayWidth::Full),
338 format::long_date_label(start.date_naive()),
339 start.format(format::clock_format())
340 )
341 }
342
337 343 /// Teams writes the weekday in full on these lines ("Thursday 11:45"), unlike message times.
338 344 fn notice_stamp(time: DateTime<Utc>, clock: &CallClock) -> String {
339 345 let local = clock.offset.at(time);
@@ -341,7 +347,7 @@ fn notice_stamp(time: DateTime<Utc>, clock: &CallClock) -> String {
341 347 if (2..=WEEKDAY_STAMP_DAYS).contains(&days_ago) {
342 348 format!(
343 349 "{} {}",
344 local.format("%A"),
350 format::weekday_name(local.weekday(), format::WeekdayWidth::Full),
345 351 local.format(app_base::format::clock_format())
346 352 )
347 353 } else {
@@ -723,6 +729,8 @@ mod tests {
723 729
724 730 #[test]
725 731 fn recap_date_prefers_the_calendar_occurrence() {
732 // Day first, as the regional format of the United Kingdom writes it.
733 format::set_date_locale(Some("en-GB"));
726 734 let started_at = Utc.with_ymd_and_hms(2026, 10, 15, 9, 46, 0).unwrap();
727 735 let ended_at = Utc.with_ymd_and_hms(2026, 10, 15, 9, 55, 0).unwrap();
728 736 let mut meeting = MeetingInfo::default();
@@ -1,7 +1,7 @@
1use std::collections::{HashMap, HashSet};
1use std::collections::{HashMap, HashSet};
2
2
3use app_base::format::Zone;
3use app_base::format::Zone;
4use chrono::{DateTime, NaiveDate, Utc};
4use chrono::{DateTime, Datelike, FixedOffset, NaiveDate, Utc};
5use store::MessageRecord;
5use store::MessageRecord;
6use teams_core::roster_event::RosterEvent;
6use teams_core::roster_event::RosterEvent;
7use teams_core::{CallEvent, CallPhase, CallType, ImageRef, format_duration};
7use teams_core::{CallEvent, CallPhase, CallType, ImageRef, format_duration};
@@ -10,7 +10,6 @@ use crate::format;
10
10
11const MAX_AVATARS: usize = 4;
11const MAX_AVATARS: usize = 4;
12const RECAP_FALLBACK_TITLE: &str = "Meeting";
12const RECAP_FALLBACK_TITLE: &str = "Meeting";
13const RECAP_DATE_FORMAT: &str = "%A, %-d %B %Y";
14const AUTO_STOP_SECONDS: i64 = 5;
13const AUTO_STOP_SECONDS: i64 = 5;
15const WEEKDAY_STAMP_DAYS: i64 = 6;
14const WEEKDAY_STAMP_DAYS: i64 = 6;
16const OWN_NAME: &str = "You";
15const OWN_NAME: &str = "You";
@@ -323,10 +322,7 @@ fn recap_date_line(
323 });
322 });
324 format!(
323 format!(
325 "{} - {}",
324 "{} - {}",
326 clock.offset.at(slot.start).format(&format!(
325 recap_start_label(clock.offset.at(slot.start)),
327 "{RECAP_DATE_FORMAT} {}",
328 app_base::format::clock_format()
329 )),
330 clock
326 clock
331 .offset
327 .offset
332 .at(slot.end)
328 .at(slot.end)
@@ -334,6 +330,16 @@ fn recap_date_line(
334 )
330 )
335}
331}
336
332
333/// "Thursday, 16. November 2026 14:30" in the app language and regional format.
334fn recap_start_label(start: DateTime<FixedOffset>) -> String {
335 format!(
336 "{}, {} {}",
337 format::weekday_name(start.weekday(), format::WeekdayWidth::Full),
338 format::long_date_label(start.date_naive()),
339 start.format(format::clock_format())
340 )
341}
342
337/// Teams writes the weekday in full on these lines ("Thursday 11:45"), unlike message times.
343/// Teams writes the weekday in full on these lines ("Thursday 11:45"), unlike message times.
338fn notice_stamp(time: DateTime<Utc>, clock: &CallClock) -> String {
344fn notice_stamp(time: DateTime<Utc>, clock: &CallClock) -> String {
339 let local = clock.offset.at(time);
345 let local = clock.offset.at(time);
@@ -341,7 +347,7 @@ fn notice_stamp(time: DateTime<Utc>, clock: &CallClock) -> String {
341 if (2..=WEEKDAY_STAMP_DAYS).contains(&days_ago) {
347 if (2..=WEEKDAY_STAMP_DAYS).contains(&days_ago) {
342 format!(
348 format!(
343 "{} {}",
349 "{} {}",
344 local.format("%A"),
350 format::weekday_name(local.weekday(), format::WeekdayWidth::Full),
345 local.format(app_base::format::clock_format())
351 local.format(app_base::format::clock_format())
346 )
352 )
347 } else {
353 } else {
@@ -723,6 +729,8 @@ mod tests {
723
729
724 #[test]
730 #[test]
725 fn recap_date_prefers_the_calendar_occurrence() {
731 fn recap_date_prefers_the_calendar_occurrence() {
732 // Day first, as the regional format of the United Kingdom writes it.
733 format::set_date_locale(Some("en-GB"));
726 let started_at = Utc.with_ymd_and_hms(2026, 10, 15, 9, 46, 0).unwrap();
734 let started_at = Utc.with_ymd_and_hms(2026, 10, 15, 9, 46, 0).unwrap();
727 let ended_at = Utc.with_ymd_and_hms(2026, 10, 15, 9, 55, 0).unwrap();
735 let ended_at = Utc.with_ymd_and_hms(2026, 10, 15, 9, 55, 0).unwrap();
728 let mut meeting = MeetingInfo::default();
736 let mut meeting = MeetingInfo::default();
crates/app-state/src/find_in_chat.rs +1 −1
@@ -250,7 +250,7 @@ pub fn month_label(date: NaiveDate, today: NaiveDate) -> String {
250 250 match months(today) - months(date) {
251 251 0 => THIS_MONTH.to_owned(),
252 252 1 => LAST_MONTH.to_owned(),
253 _ => date.format("%B %Y").to_string(),
253 _ => crate::format::month_year_label(date),
254 254 }
255 255 }
256 256
@@ -250,7 +250,7 @@ pub fn month_label(date: NaiveDate, today: NaiveDate) -> String {
250 match months(today) - months(date) {
250 match months(today) - months(date) {
251 0 => THIS_MONTH.to_owned(),
251 0 => THIS_MONTH.to_owned(),
252 1 => LAST_MONTH.to_owned(),
252 1 => LAST_MONTH.to_owned(),
253 _ => date.format("%B %Y").to_string(),
253 _ => crate::format::month_year_label(date),
254 }
254 }
255}
255}
256
256
crates/app-state/src/own_status.rs +9 −9
@@ -5,7 +5,7 @@ pub use app_base::status_choice::{
5 5 STATUS_CHOICES, STATUS_DURATIONS, StatusDuration, choice_label, end_of_day, end_of_week,
6 6 state_label,
7 7 };
8 use chrono::{DateTime, Duration, TimeZone, Utc};
8 use chrono::{DateTime, Datelike, Duration, TimeZone, Utc};
9 9 use gpui_kit::*;
10 10 use teams_core::{
11 11 ForcedAvailability, ForcedKind, PresenceStatus, StatusNote, WorkLocation, WorkLocationKind,
@@ -74,15 +74,15 @@ where
74 74 Zone::Offset: std::fmt::Display,
75 75 {
76 76 let local = expires_at.with_timezone(&now.timezone());
77 if local.date_naive() == now.date_naive() {
78 format!("until {}", local.format(app_base::format::clock_format()))
77 let clock = local.format(app_base::format::clock_format()).to_string();
78 let time = if local.date_naive() == now.date_naive() {
79 clock
79 80 } else {
80 format!(
81 "until {} {}",
82 local.format("%a"),
83 local.format(app_base::format::clock_format())
84 )
85 }
81 let weekday =
82 app_base::format::weekday_name(local.weekday(), app_base::format::WeekdayWidth::Short);
83 format!("{weekday} {clock}")
84 };
85 app_base::ui_locale::tr_with("regional.until", &[("time", &time)])
86 86 }
87 87
88 88 #[derive(Debug, Clone, PartialEq, Eq)]
@@ -5,7 +5,7 @@ pub use app_base::status_choice::{
5 STATUS_CHOICES, STATUS_DURATIONS, StatusDuration, choice_label, end_of_day, end_of_week,
5 STATUS_CHOICES, STATUS_DURATIONS, StatusDuration, choice_label, end_of_day, end_of_week,
6 state_label,
6 state_label,
7};
7};
8use chrono::{DateTime, Duration, TimeZone, Utc};
8use chrono::{DateTime, Datelike, Duration, TimeZone, Utc};
9use gpui_kit::*;
9use gpui_kit::*;
10use teams_core::{
10use teams_core::{
11 ForcedAvailability, ForcedKind, PresenceStatus, StatusNote, WorkLocation, WorkLocationKind,
11 ForcedAvailability, ForcedKind, PresenceStatus, StatusNote, WorkLocation, WorkLocationKind,
@@ -74,15 +74,15 @@ where
74 Zone::Offset: std::fmt::Display,
74 Zone::Offset: std::fmt::Display,
75{
75{
76 let local = expires_at.with_timezone(&now.timezone());
76 let local = expires_at.with_timezone(&now.timezone());
77 if local.date_naive() == now.date_naive() {
77 let clock = local.format(app_base::format::clock_format()).to_string();
78 format!("until {}", local.format(app_base::format::clock_format()))
78 let time = if local.date_naive() == now.date_naive() {
79 clock
79 } else {
80 } else {
80 format!(
81 let weekday =
81 "until {} {}",
82 app_base::format::weekday_name(local.weekday(), app_base::format::WeekdayWidth::Short);
82 local.format("%a"),
83 format!("{weekday} {clock}")
83 local.format(app_base::format::clock_format())
84 };
84 )
85 app_base::ui_locale::tr_with("regional.until", &[("time", &time)])
85 }
86}
86}
87
87
88#[derive(Debug, Clone, PartialEq, Eq)]
88#[derive(Debug, Clone, PartialEq, Eq)]
crates/app-state/src/reaction_model.rs +11 −6
@@ -1,5 +1,6 @@
1 1 use std::fmt::Display;
2 2
3 use app_base::ui_locale::tr_with;
3 4 use chrono::{DateTime, Datelike, TimeZone, Utc};
4 5
5 6 use crate::rows::ReactionChip;
@@ -67,15 +68,19 @@ where
67 68 let local = time.with_timezone(&now.timezone());
68 69 let day = local.date_naive();
69 70 let today = now.date_naive();
70 let clock = local.format(app_base::format::clock_format());
71 let clock = local.format(app_base::format::clock_format()).to_string();
72 let clock = ("clock", clock.as_str());
71 73 if day == today {
72 format!("today at {clock}")
74 tr_with("regional.today_at", &[clock])
73 75 } else if today.pred_opt() == Some(day) {
74 format!("yesterday at {clock}")
75 } else if day.year() == today.year() {
76 format!("{} at {clock}", local.format("%b %-d"))
76 tr_with("regional.yesterday_at", &[clock])
77 77 } else {
78 format!("{} at {clock}", local.format("%b %-d, %Y"))
78 let date = if day.year() == today.year() {
79 app_base::format::day_month_label(day)
80 } else {
81 app_base::format::date_label(day)
82 };
83 tr_with("regional.date_at", &[("date", &date), clock])
79 84 }
80 85 }
81 86
@@ -1,5 +1,6 @@
1use std::fmt::Display;
1use std::fmt::Display;
2
2
3use app_base::ui_locale::tr_with;
3use chrono::{DateTime, Datelike, TimeZone, Utc};
4use chrono::{DateTime, Datelike, TimeZone, Utc};
4
5
5use crate::rows::ReactionChip;
6use crate::rows::ReactionChip;
@@ -67,15 +68,19 @@ where
67 let local = time.with_timezone(&now.timezone());
68 let local = time.with_timezone(&now.timezone());
68 let day = local.date_naive();
69 let day = local.date_naive();
69 let today = now.date_naive();
70 let today = now.date_naive();
70 let clock = local.format(app_base::format::clock_format());
71 let clock = local.format(app_base::format::clock_format()).to_string();
72 let clock = ("clock", clock.as_str());
71 if day == today {
73 if day == today {
72 format!("today at {clock}")
74 tr_with("regional.today_at", &[clock])
73 } else if today.pred_opt() == Some(day) {
75 } else if today.pred_opt() == Some(day) {
74 format!("yesterday at {clock}")
76 tr_with("regional.yesterday_at", &[clock])
75 } else if day.year() == today.year() {
76 format!("{} at {clock}", local.format("%b %-d"))
77 } else {
77 } else {
78 format!("{} at {clock}", local.format("%b %-d, %Y"))
78 let date = if day.year() == today.year() {
79 app_base::format::day_month_label(day)
80 } else {
81 app_base::format::date_label(day)
82 };
83 tr_with("regional.date_at", &[("date", &date), clock])
79 }
84 }
80}
85}
81
86
crates/app-state/src/share_outlook.rs +6 −4
@@ -34,10 +34,12 @@ pub fn share_body(record: &MessageRecord, link: Option<&str>) -> String {
34 34 }
35 35
36 36 fn sent_label(sent_at: DateTime<Utc>) -> String {
37 sent_at
38 .with_timezone(&Local)
39 .format("%d/%m/%Y %H:%M")
40 .to_string()
37 let local = sent_at.with_timezone(&Local);
38 format!(
39 "{} {}",
40 crate::format::date_label(local.date_naive()),
41 local.format(crate::format::clock_format())
42 )
41 43 }
42 44
43 45 impl AppState {
@@ -34,10 +34,12 @@ pub fn share_body(record: &MessageRecord, link: Option<&str>) -> String {
34}
34}
35
35
36fn sent_label(sent_at: DateTime<Utc>) -> String {
36fn sent_label(sent_at: DateTime<Utc>) -> String {
37 sent_at
37 let local = sent_at.with_timezone(&Local);
38 .with_timezone(&Local)
38 format!(
39 .format("%d/%m/%Y %H:%M")
39 "{} {}",
40 .to_string()
40 crate::format::date_label(local.date_naive()),
41 local.format(crate::format::clock_format())
42 )
41}
43}
42
44
43impl AppState {
45impl AppState {
crates/app/src/views/calendar_event_dialog.rs +7 −39
@@ -1,13 +1,13 @@
1 1 use std::collections::HashMap;
2 2
3 use app_base::format::Zone;
3 use app_base::format::{WeekdayWidth, Zone, weekday_name};
4 4 use app_ui_kit::layout::{COMFY_RUNWAY_WIDTH, SIDEBAR_WIDTH};
5 5 use app_ui_kit::render::hooks::open_link;
6 6 use app_ui_kit::render::{Block, layout_blocks, render_blocks, strip_image_placeholders};
7 7 use chatsvc::{
8 8 CalendarEvent, CalendarSource, DialIn, EventAttendee, Reply, ResponseType, join_info_text,
9 9 };
10 use chrono::{Datelike, Weekday};
10 use chrono::Datelike;
11 11 use gpui_kit::assets::IconName;
12 12 use gpui_kit::component::Sizable as _;
13 13 use gpui_kit::component::button::{Button, ButtonVariants as _};
@@ -1026,8 +1026,8 @@ fn peek_when_label(event: &CalendarEvent) -> String {
1026 1026 let day_label = |date: chrono::NaiveDate| {
1027 1027 format!(
1028 1028 "{} {}",
1029 localized_weekday(date.weekday()),
1030 format_peek_date(date)
1029 weekday_name(date.weekday(), WeekdayWidth::Short),
1030 app_base::format::date_label(date)
1031 1031 )
1032 1032 };
1033 1033 let (start, end) = (start.date_naive(), end.date_naive());
@@ -1041,8 +1041,8 @@ fn peek_when_label(event: &CalendarEvent) -> String {
1041 1041 }
1042 1042 return format!("{} · {}", tr("calendar.peek.all_day"), day_label(start));
1043 1043 }
1044 let weekday = localized_weekday(start.weekday());
1045 let date = format_peek_date(start.date_naive());
1044 let weekday = weekday_name(start.weekday(), WeekdayWidth::Short);
1045 let date = app_base::format::date_label(start.date_naive());
1046 1046 let clock = app_base::format::clock_format();
1047 1047 if start.date_naive() == end.date_naive() {
1048 1048 format!(
@@ -1055,7 +1055,7 @@ fn peek_when_label(event: &CalendarEvent) -> String {
1055 1055 format!(
1056 1056 "{weekday} {date}, {} – {}, {}",
1057 1057 start.format(clock),
1058 format_peek_date(end.date_naive()),
1058 app_base::format::date_label(end.date_naive()),
1059 1059 end.format(clock)
1060 1060 )
1061 1061 }
@@ -1101,38 +1101,6 @@ fn reminder_label(minutes: u32) -> String {
1101 1101 )
1102 1102 }
1103 1103
1104 fn ui_is_german() -> bool {
1105 gpui_kit::component::locale().starts_with("de")
1106 }
1107
1108 fn format_peek_date(date: chrono::NaiveDate) -> String {
1109 if ui_is_german() {
1110 date.format("%d.%m.%Y").to_string()
1111 } else {
1112 date.format("%-m/%-d/%Y").to_string()
1113 }
1114 }
1115
1116 fn localized_weekday(weekday: Weekday) -> &'static str {
1117 let de = ui_is_german();
1118 match (de, weekday) {
1119 (true, Weekday::Mon) => "Mo",
1120 (true, Weekday::Tue) => "Di",
1121 (true, Weekday::Wed) => "Mi",
1122 (true, Weekday::Thu) => "Do",
1123 (true, Weekday::Fri) => "Fr",
1124 (true, Weekday::Sat) => "Sa",
1125 (true, Weekday::Sun) => "So",
1126 (false, Weekday::Mon) => "Mon",
1127 (false, Weekday::Tue) => "Tue",
1128 (false, Weekday::Wed) => "Wed",
1129 (false, Weekday::Thu) => "Thu",
1130 (false, Weekday::Fri) => "Fri",
1131 (false, Weekday::Sat) => "Sat",
1132 (false, Weekday::Sun) => "Sun",
1133 }
1134 }
1135
1136 1104 fn location_label(event: &CalendarEvent) -> String {
1137 1105 if let Some(location) = event.location.clone().filter(|value| !value.is_empty()) {
1138 1106 return location;
@@ -1,13 +1,13 @@
1use std::collections::HashMap;
1use std::collections::HashMap;
2
2
3use app_base::format::Zone;
3use app_base::format::{WeekdayWidth, Zone, weekday_name};
4use app_ui_kit::layout::{COMFY_RUNWAY_WIDTH, SIDEBAR_WIDTH};
4use app_ui_kit::layout::{COMFY_RUNWAY_WIDTH, SIDEBAR_WIDTH};
5use app_ui_kit::render::hooks::open_link;
5use app_ui_kit::render::hooks::open_link;
6use app_ui_kit::render::{Block, layout_blocks, render_blocks, strip_image_placeholders};
6use app_ui_kit::render::{Block, layout_blocks, render_blocks, strip_image_placeholders};
7use chatsvc::{
7use chatsvc::{
8 CalendarEvent, CalendarSource, DialIn, EventAttendee, Reply, ResponseType, join_info_text,
8 CalendarEvent, CalendarSource, DialIn, EventAttendee, Reply, ResponseType, join_info_text,
9};
9};
10use chrono::{Datelike, Weekday};
10use chrono::Datelike;
11use gpui_kit::assets::IconName;
11use gpui_kit::assets::IconName;
12use gpui_kit::component::Sizable as _;
12use gpui_kit::component::Sizable as _;
13use gpui_kit::component::button::{Button, ButtonVariants as _};
13use gpui_kit::component::button::{Button, ButtonVariants as _};
@@ -1026,8 +1026,8 @@ fn peek_when_label(event: &CalendarEvent) -> String {
1026 let day_label = |date: chrono::NaiveDate| {
1026 let day_label = |date: chrono::NaiveDate| {
1027 format!(
1027 format!(
1028 "{} {}",
1028 "{} {}",
1029 localized_weekday(date.weekday()),
1029 weekday_name(date.weekday(), WeekdayWidth::Short),
1030 format_peek_date(date)
1030 app_base::format::date_label(date)
1031 )
1031 )
1032 };
1032 };
1033 let (start, end) = (start.date_naive(), end.date_naive());
1033 let (start, end) = (start.date_naive(), end.date_naive());
@@ -1041,8 +1041,8 @@ fn peek_when_label(event: &CalendarEvent) -> String {
1041 }
1041 }
1042 return format!("{} · {}", tr("calendar.peek.all_day"), day_label(start));
1042 return format!("{} · {}", tr("calendar.peek.all_day"), day_label(start));
1043 }
1043 }
1044 let weekday = localized_weekday(start.weekday());
1044 let weekday = weekday_name(start.weekday(), WeekdayWidth::Short);
1045 let date = format_peek_date(start.date_naive());
1045 let date = app_base::format::date_label(start.date_naive());
1046 let clock = app_base::format::clock_format();
1046 let clock = app_base::format::clock_format();
1047 if start.date_naive() == end.date_naive() {
1047 if start.date_naive() == end.date_naive() {
1048 format!(
1048 format!(
@@ -1055,7 +1055,7 @@ fn peek_when_label(event: &CalendarEvent) -> String {
1055 format!(
1055 format!(
1056 "{weekday} {date}, {} – {}, {}",
1056 "{weekday} {date}, {} – {}, {}",
1057 start.format(clock),
1057 start.format(clock),
1058 format_peek_date(end.date_naive()),
1058 app_base::format::date_label(end.date_naive()),
1059 end.format(clock)
1059 end.format(clock)
1060 )
1060 )
1061 }
1061 }
@@ -1101,38 +1101,6 @@ fn reminder_label(minutes: u32) -> String {
1101 )
1101 )
1102}
1102}
1103
1103
1104fn ui_is_german() -> bool {
1105 gpui_kit::component::locale().starts_with("de")
1106}
1107
1108fn format_peek_date(date: chrono::NaiveDate) -> String {
1109 if ui_is_german() {
1110 date.format("%d.%m.%Y").to_string()
1111 } else {
1112 date.format("%-m/%-d/%Y").to_string()
1113 }
1114}
1115
1116fn localized_weekday(weekday: Weekday) -> &'static str {
1117 let de = ui_is_german();
1118 match (de, weekday) {
1119 (true, Weekday::Mon) => "Mo",
1120 (true, Weekday::Tue) => "Di",
1121 (true, Weekday::Wed) => "Mi",
1122 (true, Weekday::Thu) => "Do",
1123 (true, Weekday::Fri) => "Fr",
1124 (true, Weekday::Sat) => "Sa",
1125 (true, Weekday::Sun) => "So",
1126 (false, Weekday::Mon) => "Mon",
1127 (false, Weekday::Tue) => "Tue",
1128 (false, Weekday::Wed) => "Wed",
1129 (false, Weekday::Thu) => "Thu",
1130 (false, Weekday::Fri) => "Fri",
1131 (false, Weekday::Sat) => "Sat",
1132 (false, Weekday::Sun) => "Sun",
1133 }
1134}
1135
1136fn location_label(event: &CalendarEvent) -> String {
1104fn location_label(event: &CalendarEvent) -> String {
1137 if let Some(location) = event.location.clone().filter(|value| !value.is_empty()) {
1105 if let Some(location) = event.location.clone().filter(|value| !value.is_empty()) {
1138 return location;
1106 return location;
crates/app/src/views/meeting_proposal_card.rs +3 −6
@@ -19,16 +19,13 @@ const DESCRIPTION_LINES: usize = 3;
19 19 pub fn when_label(start: DateTime<Utc>, end: DateTime<Utc>) -> String {
20 20 let (start, end) = (start.with_timezone(&Local), end.with_timezone(&Local));
21 21 let clock = crate::format::clock_format();
22 let day = |time: DateTime<Local>| crate::format::weekday_date_label(time.date_naive());
22 23 let end_text = if end.date_naive() == start.date_naive() {
23 24 end.format(clock).to_string()
24 25 } else {
25 format!("{} {}", end.format("%a %-d %b,"), end.format(clock))
26 format!("{} {}", day(end), end.format(clock))
26 27 };
27 format!(
28 "{} {} - {end_text}",
29 start.format("%a %-d %b,"),
30 start.format(clock)
31 )
28 format!("{} {} - {end_text}", day(start), start.format(clock))
32 29 }
33 30
34 31 fn description_excerpt(description: &str) -> Option<String> {
@@ -19,16 +19,13 @@ const DESCRIPTION_LINES: usize = 3;
19pub fn when_label(start: DateTime<Utc>, end: DateTime<Utc>) -> String {
19pub fn when_label(start: DateTime<Utc>, end: DateTime<Utc>) -> String {
20 let (start, end) = (start.with_timezone(&Local), end.with_timezone(&Local));
20 let (start, end) = (start.with_timezone(&Local), end.with_timezone(&Local));
21 let clock = crate::format::clock_format();
21 let clock = crate::format::clock_format();
22 let day = |time: DateTime<Local>| crate::format::weekday_date_label(time.date_naive());
22 let end_text = if end.date_naive() == start.date_naive() {
23 let end_text = if end.date_naive() == start.date_naive() {
23 end.format(clock).to_string()
24 end.format(clock).to_string()
24 } else {
25 } else {
25 format!("{} {}", end.format("%a %-d %b,"), end.format(clock))
26 format!("{} {}", day(end), end.format(clock))
26 };
27 };
27 format!(
28 format!("{} {} - {end_text}", day(start), start.format(clock))
28 "{} {} - {end_text}",
29 start.format("%a %-d %b,"),
30 start.format(clock)
31 )
32}
29}
33
30
34fn description_excerpt(description: &str) -> Option<String> {
31fn description_excerpt(description: &str) -> Option<String> {