Skip to content

Commit f39fdd2

Browse files
authored
Merge pull request #7146 from cakebaker/bump_chrono_tz
Bump `chrono-tz` to `0.10.0`
2 parents 3913152 + 7edd045 commit f39fdd2

File tree

5 files changed

+21
-14
lines changed

5 files changed

+21
-14
lines changed

Cargo.lock

Lines changed: 4 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -278,10 +278,9 @@ chrono = { version = "0.4.38", default-features = false, features = [
278278
"alloc",
279279
"clock",
280280
] }
281+
chrono-tz = "0.10.0"
281282
clap = { version = "4.5", features = ["wrap_help", "cargo"] }
282283
clap_complete = "4.4"
283-
chrono-tz = "0.8.3"
284-
iana-time-zone = "0.1.57"
285284
clap_mangen = "0.2"
286285
compare = "0.1.0"
287286
coz = { version = "0.1.3" }
@@ -299,6 +298,7 @@ gcd = "2.3"
299298
glob = "0.3.1"
300299
half = "2.4.1"
301300
hostname = "0.4"
301+
iana-time-zone = "0.1.57"
302302
indicatif = "0.17.8"
303303
itertools = "0.14.0"
304304
libc = "0.2.153"

fuzz/Cargo.lock

Lines changed: 4 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/uu/date/src/date.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
277277
// TODO - Revisit when chrono 0.5 is released. https://github.com/chronotope/chrono/issues/970
278278
let tz = match std::env::var("TZ") {
279279
// TODO Support other time zones...
280-
Ok(s) if s == "UTC0" => Tz::Etc__UTC,
280+
Ok(s) if s == "UTC0" || s.is_empty() => Tz::Etc__UTC,
281281
_ => match get_timezone() {
282282
Ok(tz_str) => tz_str.parse().unwrap(),
283283
Err(_) => Tz::Etc__UTC,
@@ -288,7 +288,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
288288
// GNU `date` uses `%N` for nano seconds, however crate::chrono uses `%f`
289289
let format_string = &format_string
290290
.replace("%N", "%f")
291-
.replace("%Z", tz_abbreviation);
291+
.replace("%Z", tz_abbreviation.unwrap_or("UTC"));
292292
// Refuse to pass this string to chrono as it is crashing in this crate
293293
if format_string.contains("%#z") {
294294
return Err(USimpleError::new(

tests/by-util/test_date.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -482,3 +482,12 @@ fn test_date_from_stdin() {
482482
Sat Apr 15 18:30:00 UTC 2023\n",
483483
);
484484
}
485+
486+
#[test]
487+
fn test_date_empty_tz() {
488+
new_ucmd!()
489+
.env("TZ", "")
490+
.arg("+%Z")
491+
.succeeds()
492+
.stdout_only("UTC\n");
493+
}

0 commit comments

Comments
 (0)