Timezones a-la chrono-tz #351
-
Fixed offsets do not take summer times and others into account. Is there a sibling crate with definitions of other timezones? We use Operations where we use chrono and chrono-tz: /// Adds an `interval` to a `timestamp` in `time_unit` units without timezone.
pub fn add_naive_interval(timestamp: i64, time_unit: TimeUnit, interval: months_days_ns) -> i64;
/// Adds an `interval` to a `timestamp` in `time_unit` units and timezone `timezone`.
pub fn add_interval<T: chrono::TimeZone>(
timestamp: i64,
time_unit: TimeUnit,
interval: months_days_ns, // [i32, i32, i64]
timezone: &T,
) -> i64
/// Time units defined in Arrow.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum TimeUnit {
/// Time in seconds.
Second,
/// Time in milliseconds.
Millisecond,
/// Time in microseconds.
Microsecond,
/// Time in nanoseconds.
Nanosecond,
}
/// The in-memory representation of the MonthDayNano variant of the "Interval" logical type.
pub struct months_days_ns(i32, i32, i64); Adding days and ns to a datetime with a timezone requires these non-trivial time-shifts. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 6 replies
-
Looks like you're asking for two separate things here: tzdb integration and a tzdb support (tracked by #193) is what will provide time zones rather than just fixed offsets. This will let you subtract two dates over a DST shift and get the appropriate A |
Beta Was this translation helpful? Give feedback.
Looks like you're asking for two separate things here: tzdb integration and a
Period
type. Both are planned.tzdb support (tracked by #193) is what will provide time zones rather than just fixed offsets. This will let you subtract two dates over a DST shift and get the appropriate
Duration
(such as 23 or 25 hours rather than 24).A
Period
type is what will allow you to take January 1 and add one month, rather than requiring a number of days (which of course varies by month). It would be able to be added to and subtracted from all of the types you'd expect. That will includeZonedDateTime
or whatever it ends up being called.