Skip to main content

teksilo_widgets/common/datetime/
month_names.rs

1// SPDX-License-Identifier: MPL-2.0
2// SPDX-FileCopyrightText: 2026 FernTech
3
4//! Localized month names — `tr_widget!` keys grouped by width.
5
6/// Long month name key (e.g. "January"). Month is `1..=12`; out-of-range
7/// inputs return January's key (caller bug — months never come from user
8/// input in the calendar code path).
9pub fn month_long_key(month: i8) -> &'static str {
10    match month {
11        1 => "calendar-month-long-january",
12        2 => "calendar-month-long-february",
13        3 => "calendar-month-long-march",
14        4 => "calendar-month-long-april",
15        5 => "calendar-month-long-may",
16        6 => "calendar-month-long-june",
17        7 => "calendar-month-long-july",
18        8 => "calendar-month-long-august",
19        9 => "calendar-month-long-september",
20        10 => "calendar-month-long-october",
21        11 => "calendar-month-long-november",
22        12 => "calendar-month-long-december",
23        _ => "calendar-month-long-january",
24    }
25}
26
27/// Short month name key (e.g. "Jan").
28pub fn month_short_key(month: i8) -> &'static str {
29    match month {
30        1 => "calendar-month-short-january",
31        2 => "calendar-month-short-february",
32        3 => "calendar-month-short-march",
33        4 => "calendar-month-short-april",
34        5 => "calendar-month-short-may",
35        6 => "calendar-month-short-june",
36        7 => "calendar-month-short-july",
37        8 => "calendar-month-short-august",
38        9 => "calendar-month-short-september",
39        10 => "calendar-month-short-october",
40        11 => "calendar-month-short-november",
41        12 => "calendar-month-short-december",
42        _ => "calendar-month-short-january",
43    }
44}