Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions arrow-array/src/timezone.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ mod private {
use super::*;
use chrono::offset::TimeZone;
use chrono::{LocalResult, NaiveDate, NaiveDateTime, Offset};
use std::fmt::Display;
use std::str::FromStr;

/// An [`Offset`] for [`Tz`]
Expand Down Expand Up @@ -97,6 +98,15 @@ mod private {
}
}

impl Display for Tz {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self.0 {
TzInner::Timezone(tz) => tz.fmt(f),
TzInner::Offset(offset) => offset.fmt(f),
}
}
}

macro_rules! tz {
($s:ident, $tz:ident, $b:block) => {
match $s.0 {
Expand Down Expand Up @@ -228,6 +238,15 @@ mod private {
sydney_offset_with_dst
);
}

#[test]
fn test_timezone_display() {
let test_cases = ["UTC", "America/Los_Angeles", "-08:00", "+05:30"];
for &case in &test_cases {
let tz: Tz = case.parse().unwrap();
assert_eq!(tz.to_string(), case);
}
}
}
}

Expand Down
Loading