mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 11:37:44 +00:00
date: use UTC if TZ is empty
This commit is contained in:
parent
ada18863a7
commit
7edd045206
2 changed files with 10 additions and 1 deletions
|
@ -277,7 +277,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
|||
// TODO - Revisit when chrono 0.5 is released. https://github.com/chronotope/chrono/issues/970
|
||||
let tz = match std::env::var("TZ") {
|
||||
// TODO Support other time zones...
|
||||
Ok(s) if s == "UTC0" => Tz::Etc__UTC,
|
||||
Ok(s) if s == "UTC0" || s.is_empty() => Tz::Etc__UTC,
|
||||
_ => match get_timezone() {
|
||||
Ok(tz_str) => tz_str.parse().unwrap(),
|
||||
Err(_) => Tz::Etc__UTC,
|
||||
|
|
|
@ -482,3 +482,12 @@ fn test_date_from_stdin() {
|
|||
Sat Apr 15 18:30:00 UTC 2023\n",
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_date_empty_tz() {
|
||||
new_ucmd!()
|
||||
.env("TZ", "")
|
||||
.arg("+%Z")
|
||||
.succeeds()
|
||||
.stdout_only("UTC\n");
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue