Merge pull request #8666 from bakanovskii/fix-pinky-time-format

pinky: fix time format
This commit is contained in:
Daniel Hofstetter
2025-09-19 15:17:47 +02:00
committed by GitHub
+13 -4
View File
@@ -136,11 +136,20 @@ fn idle_string(when: i64) -> String {
}
fn time_string(ut: &UtmpxRecord) -> String {
// "%b %e %H:%M"
let time_format: Vec<time::format_description::FormatItem> =
let lc_time: String = std::env::var("LC_ALL")
.or_else(|_| std::env::var("LC_TIME"))
.or_else(|_| std::env::var("LANG"))
.unwrap_or_default();
let time_format: Vec<time::format_description::FormatItem> = if lc_time == "C" {
// "%b %e %H:%M"
time::format_description::parse("[month repr:short] [day padding:space] [hour]:[minute]")
.unwrap();
ut.login_time().format(&time_format).unwrap() // LC_ALL=C
.unwrap()
} else {
// "%Y-%m-%d %H:%M"
time::format_description::parse("[year]-[month]-[day] [hour]:[minute]").unwrap()
};
ut.login_time().format(&time_format).unwrap()
}
fn gecos_to_fullname(pw: &Passwd) -> Option<String> {