Skip to content

Commit

Permalink
Merge pull request #7146 from cakebaker/bump_chrono_tz
Browse files Browse the repository at this point in the history
Bump `chrono-tz` to `0.10.0`
  • Loading branch information
sylvestre authored Jan 16, 2025
2 parents 3913152 + 7edd045 commit f39fdd2
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 14 deletions.
9 changes: 4 additions & 5 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -278,10 +278,9 @@ chrono = { version = "0.4.38", default-features = false, features = [
"alloc",
"clock",
] }
chrono-tz = "0.10.0"
clap = { version = "4.5", features = ["wrap_help", "cargo"] }
clap_complete = "4.4"
chrono-tz = "0.8.3"
iana-time-zone = "0.1.57"
clap_mangen = "0.2"
compare = "0.1.0"
coz = { version = "0.1.3" }
Expand All @@ -299,6 +298,7 @@ gcd = "2.3"
glob = "0.3.1"
half = "2.4.1"
hostname = "0.4"
iana-time-zone = "0.1.57"
indicatif = "0.17.8"
itertools = "0.14.0"
libc = "0.2.153"
Expand Down
9 changes: 4 additions & 5 deletions fuzz/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src/uu/date/src/date.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -288,7 +288,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
// GNU `date` uses `%N` for nano seconds, however crate::chrono uses `%f`
let format_string = &format_string
.replace("%N", "%f")
.replace("%Z", tz_abbreviation);
.replace("%Z", tz_abbreviation.unwrap_or("UTC"));
// Refuse to pass this string to chrono as it is crashing in this crate
if format_string.contains("%#z") {
return Err(USimpleError::new(
Expand Down
9 changes: 9 additions & 0 deletions tests/by-util/test_date.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}

0 comments on commit f39fdd2

Please sign in to comment.