Skip to main content

GapInfo

Struct GapInfo 

pub struct GapInfo {
    pub begin: Option<(NaiveDateTime, TzOffset)>,
    pub end: Option<DateTime<Tz>>,
}
Expand description

Represents the information of a gap.

This returns useful information that can be used when converting a local NaiveDateTime to a timezone-aware DateTime with chrono::TimeZone::from_local_datetime and a gap (chrono::LocalResult::None) is found.

§Examples

In the America/New_York timezone the clocks went forward one hour at 2026-03-08T02:00:00. The local time 2026-03-08T01:30:00 exists, but 2026-03-08T02:30:00 falls in the gap and does not.

use arrow_array::timezone::{GapInfo, Tz};
use chrono::{DateTime, FixedOffset, LocalResult, NaiveDateTime, Offset, TimeZone};

let tz: Tz = "America/New_York".parse().unwrap();
let expect_offset: FixedOffset = "-0500".parse().unwrap();

// A local time before the gap has a single offset, and is not in a gap.
let exists: NaiveDateTime = "2026-03-08T01:30:00".parse().unwrap();
let offset = tz.offset_from_local_datetime(&exists).single().unwrap();
assert_eq!(offset.fix(), expect_offset);
assert!(GapInfo::new(&exists, &tz).is_none());

// A local time inside the gap has no offset...
let not_exist: NaiveDateTime = "2026-03-08T02:30:00".parse().unwrap();
let offset = tz.offset_from_local_datetime(&not_exist);
assert!(matches!(offset, LocalResult::None));

// ...but `GapInfo` describes the gap it falls in.
let GapInfo { begin, end } = GapInfo::new(&not_exist, &tz).unwrap();

// The gap begins at 02:00 local time. The offset is the one in effect before the gap.
let (begin_datetime, begin_offset) = begin.unwrap();
let expect_begin: NaiveDateTime = "2026-03-08T02:00:00".parse().unwrap();
assert_eq!(begin_datetime, expect_begin);
assert_eq!(begin_offset.fix(), expect_offset);

// The gap ends at 03:00 local time, with the offset in effect after the gap.
let expect_end: DateTime<FixedOffset> = "2026-03-08T03:00:00-0400".parse().unwrap();
assert_eq!(end.unwrap(), expect_end.with_timezone(&tz));

Fields§

§begin: Option<(NaiveDateTime, TzOffset)>

When available it contains information about the beginning of the gap.

The time represents the first instant in which the gap starts. This means that it is the first instant that when used with chrono::TimeZone::from_local_datetime it will return chrono::LocalResult::None.

The offset represents the offset of the first instant before the gap.

§end: Option<DateTime<Tz>>

When available it contains the first instant after the gap.

Implementations§

§

impl GapInfo

pub fn new(local: &NaiveDateTime, tz: &Tz) -> Option<GapInfo>

Return information about a gap.

It returns None if local is not in a gap for the current timezone. Timezones that represent fixed offsets contain no gaps and therefore always return None.

If local is at the limits of the known timestamps the fields begin or end in GapInfo will be None.

Trait Implementations§

§

impl Clone for GapInfo

§

fn clone(&self) -> GapInfo

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
§

impl Copy for GapInfo

§

impl Debug for GapInfo

§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

§

impl<T> Allocation for T
where T: RefUnwindSafe + Send + Sync,

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> Ungil for T
where T: Send,