yyyy-mm-dd

This commit is contained in:
2026-02-10 23:33:58 +09:00
parent f3c1838219
commit 787d9c2e83
3 changed files with 431 additions and 296 deletions

View File

@@ -1,6 +1,6 @@
use chrono::{
DateTime, Datelike, Days, Local, LocalResult, NaiveDate, NaiveDateTime, NaiveTime, TimeZone,
Timelike, Utc, Weekday,
Timelike, Utc,
};
use log::{debug, error, info, trace, warn};
use serde::{Deserialize, Serialize};
@@ -182,9 +182,9 @@ impl StateInner {
let now_utc = now_local.with_timezone(&Utc);
let clock = ClockState {
local_time: format_time(now_local.hour(), now_local.minute(), now_local.second()),
local_date: format_date(now_local.weekday(), now_local.month(), now_local.day()),
local_date: format_date(now_local.year(), now_local.month(), now_local.day()),
utc_time: format_time(now_utc.hour(), now_utc.minute(), now_utc.second()),
utc_date: format_date(now_utc.weekday(), now_utc.month(), now_utc.day()),
utc_date: format_date(now_utc.year(), now_utc.month(), now_utc.day()),
};
let alarms = self.build_alarm_view(now_ms);
let timer = self.build_timer_view();
@@ -682,17 +682,8 @@ fn format_time(hour: u32, minute: u32, second: u32) -> String {
format!("{:02}:{:02}:{:02}", hour, minute, second)
}
fn format_date(weekday: Weekday, month: u32, day: u32) -> String {
let weekday_label = match weekday {
Weekday::Mon => "",
Weekday::Tue => "",
Weekday::Wed => "",
Weekday::Thu => "",
Weekday::Fri => "",
Weekday::Sat => "",
Weekday::Sun => "",
};
format!("{} {}{:02}", weekday_label, month, day)
fn format_date(year: i32, month: u32, day: u32) -> String {
format!("{year:04}-{month:02}-{day:02}")
}
fn format_time_label(hour: u8, minute: u8) -> String {