From 8d5d01bbc950f0bd3bad46f318438d2300664cca Mon Sep 17 00:00:00 2001 From: Douglas <32344964+NotTheDr01ds@users.noreply.github.com> Date: Tue, 11 Mar 2025 11:57:37 -0400 Subject: [PATCH] Fix improper application of local timezone offset to Unix epochs (#15283) Fix failing test by ignoring the local offset when converting times, but still displaying the resulting date in the local timezone (including applicable DST offset). # User-Facing Changes Fix: Unix Epochs now convert consistently regardless of whether DST is in effect in the local timezone or not. --- crates/nu-command/src/conversions/into/datetime.rs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/crates/nu-command/src/conversions/into/datetime.rs b/crates/nu-command/src/conversions/into/datetime.rs index 0fc9725bcf..54930bbc45 100644 --- a/crates/nu-command/src/conversions/into/datetime.rs +++ b/crates/nu-command/src/conversions/into/datetime.rs @@ -408,13 +408,10 @@ fn action(input: &Value, args: &Arguments, head: Span) -> Value { Err(reason) => { match NaiveDateTime::parse_from_str(val, &dt.0) { Ok(d) => { - let local_offset = *Local::now().offset(); let dt_fixed = - TimeZone::from_local_datetime(&local_offset, &d) - .single() - .unwrap_or_default(); + Local.from_local_datetime(&d).single().unwrap_or_default(); - Value::date (dt_fixed,head) + Value::date(dt_fixed.into(),head) } Err(_) => { Value::error (