BurntSushi commented on code in PR #11482:
URL: https://github.com/apache/arrow-rs/pull/11482#discussion_r4507775259


##########
arrow-array/src/timezone.rs:
##########
@@ -35,7 +77,604 @@ fn parse_fixed_offset(tz: &str) -> Option<FixedOffset> {
     }
 }
 
-#[cfg(feature = "chrono-tz")]
+#[cfg(feature = "jiff")]
+mod private {
+    use super::*;
+    use chrono::offset::TimeZone;
+    use chrono::{Datelike, LocalResult, NaiveDate, NaiveDateTime, NaiveTime, 
Offset, Timelike};
+    use jiff::Timestamp;
+    use jiff::civil::DateTime as JiffDateTime;
+    use jiff::tz::{AmbiguousOffset, TimeZone as JiffTimeZone};
+    use std::collections::HashMap;
+    use std::fmt::Display;
+    use std::str::FromStr;
+    use std::sync::OnceLock;
+
+    /// An [`Offset`] for [`Tz`]
+    #[derive(Debug, Copy, Clone)]
+    pub struct TzOffset {
+        tz: Tz,
+        offset: FixedOffset,
+    }
+
+    impl std::fmt::Display for TzOffset {
+        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+            self.offset.fmt(f)
+        }
+    }
+
+    impl Offset for TzOffset {
+        fn fix(&self) -> FixedOffset {
+            self.offset
+        }
+    }
+
+    /// A named timezone resolved by jiff, together with its name.
+    struct NamedTz {
+        name: &'static str,
+        tz: JiffTimeZone,
+    }
+
+    /// Prints only the name, so that `Debug` output matches the `chrono-tz` 
feature.
+    impl std::fmt::Debug for NamedTz {
+        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+            f.write_str(self.name)
+        }
+    }
+
+    /// Builds a timezone from the database in jiff-tzdb.
+    ///
+    /// Names are not resolved through `jiff::tz::db()`: if any crate in the 
build enables jiff's
+    /// `tzdb-zoneinfo` feature, that reads the host's zoneinfo files, or 
`$TZDIR`, instead. Reading
+    /// jiff-tzdb directly also means [`tzdb_version`] always describes the 
data in use.
+    fn bundled_tz(name: &str) -> Option<JiffTimeZone> {
+        // As jiff's own bundled database does, so that UTC is not backed by 
TZif data
+        if name == "UTC" {
+            return Some(JiffTimeZone::UTC);
+        }

Review Comment:
   Ah okay! Thank you for that additional context.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to