mirror of
https://github.com/uutils/coreutils.git
synced 2026-06-10 15:48:22 -07:00
date: use UTC if TZ is empty
This commit is contained in:
@@ -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");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user