mirror of
https://github.com/uutils/coreutils.git
synced 2026-06-10 15:48:22 -07:00
Merge pull request #8666 from bakanovskii/fix-pinky-time-format
pinky: fix time format
This commit is contained in:
@@ -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> {
|
||||
|
||||
Reference in New Issue
Block a user