yyyy-mm-dd
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user