Skip to content

Commit c8181a1

Browse files
xtqqczzecakebaker
authored andcommitted
who: use var_os
1 parent 72ec8cf commit c8181a1

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

src/uu/who/src/platform/unix.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -161,12 +161,12 @@ fn idle_string<'a>(when: i64, boottime: i64) -> Cow<'a, str> {
161161
}
162162

163163
fn time_string(ut: &UtmpxRecord) -> String {
164-
let lc_time = std::env::var("LC_ALL")
165-
.or_else(|_| std::env::var("LC_TIME"))
166-
.or_else(|_| std::env::var("LANG"))
167-
.unwrap_or_default();
168-
169-
let time_format: Vec<time::format_description::FormatItem> = if lc_time == "C" {
164+
let time_format: Vec<time::format_description::FormatItem> = if ["LC_ALL", "LC_TIME", "LANG"]
165+
.into_iter()
166+
.find_map(std::env::var_os)
167+
.as_deref()
168+
== Some(std::ffi::OsStr::new("C"))
169+
{
170170
// "%b %e %H:%M"
171171
time::format_description::parse("[month repr:short] [day padding:space] [hour]:[minute]")
172172
.unwrap()

0 commit comments

Comments
 (0)