Skip to content

Commit

Permalink
fix: use UTC if no TZ is found
Browse files Browse the repository at this point in the history
  • Loading branch information
erwinvaneijk committed Jan 10, 2025
1 parent c464de3 commit 4147572
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/output/render/times.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use crate::output::cell::TextCell;
use crate::output::time::TimeFormat;

use chrono::prelude::*;
use chrono_tz::Etc::UTC;
use nu_ansi_term::Style;

pub trait Render {
Expand All @@ -17,7 +18,7 @@ pub trait Render {
impl Render for Option<NaiveDateTime> {
fn render(self, style: Style, time_format: TimeFormat) -> TextCell {
let datestamp = if let Ok(timezone_str) = iana_time_zone::get_timezone() {
let timezone: chrono_tz::Tz = timezone_str.parse().unwrap();
let timezone: chrono_tz::Tz = timezone_str.parse().unwrap_or(UTC);
if let Some(time) = self {
let time_offset = timezone.offset_from_utc_datetime(&time).fix();
time_format.format(&DateTime::<FixedOffset>::from_naive_utc_and_offset(
Expand Down

0 comments on commit 4147572

Please sign in to comment.