22// SPDX-FileCopyrightText: Copyright the Vortex contributors
33
44use std:: fmt:: Display ;
5+ use std:: sync:: Arc ;
56
67use vortex_error:: VortexResult ;
78
89use crate :: datetime:: Date ;
910use crate :: datetime:: Time ;
11+ use crate :: datetime:: TimeUnit ;
1012use crate :: datetime:: Timestamp ;
11- use crate :: datetime:: TimestampOptions ;
1213use crate :: extension:: ExtDTypeRef ;
1314use crate :: extension:: ExtDTypeVTable ;
1415use crate :: extension:: Matcher ;
@@ -21,7 +22,7 @@ impl Matcher for AnyTemporal {
2122
2223 fn try_match < ' a > ( item : & ' a ExtDTypeRef ) -> Option < Self :: Match < ' a > > {
2324 if let Some ( opts) = item. metadata_opt :: < Timestamp > ( ) {
24- return Some ( TemporalMetadata :: Timestamp ( opts) ) ;
25+ return Some ( TemporalMetadata :: Timestamp ( ( & opts. unit , & opts . tz ) ) ) ;
2526 }
2627 if let Some ( opts) = item. metadata_opt :: < Date > ( ) {
2728 return Some ( TemporalMetadata :: Date ( opts) ) ;
@@ -36,8 +37,8 @@ impl Matcher for AnyTemporal {
3637/// Metadata for temporal extension data types.
3738#[ derive( Debug , PartialEq , Eq ) ]
3839pub enum TemporalMetadata < ' a > {
39- /// Metadata for Timestamp dtypes
40- Timestamp ( & ' a < Timestamp as ExtDTypeVTable > :: Metadata ) ,
40+ /// Metadata for Timestamp dtypes, a tuple of time unit and optional timezone.
41+ Timestamp ( ( & ' a TimeUnit , & ' a Option < Arc < str > > ) ) ,
4142 /// Metadata for Date dtypes
4243 Date ( & ' a <Date as ExtDTypeVTable >:: Metadata ) ,
4344 /// Metadata for Time dtypes
@@ -48,11 +49,11 @@ pub enum TemporalMetadata<'a> {
4849// Currently this is used largely to implement scalar display hacks.
4950impl TemporalMetadata < ' _ > {
5051 /// Get the time unit of the temporal dtype.
51- pub fn time_unit ( & self ) -> crate :: datetime :: TimeUnit {
52+ pub fn time_unit ( & self ) -> TimeUnit {
5253 match self {
5354 TemporalMetadata :: Time ( unit) => * * unit,
5455 TemporalMetadata :: Date ( unit) => * * unit,
55- TemporalMetadata :: Timestamp ( opts ) => opts . unit ,
56+ TemporalMetadata :: Timestamp ( ( unit , _tz ) ) => * * unit,
5657 }
5758 }
5859
@@ -65,7 +66,7 @@ impl TemporalMetadata<'_> {
6566 TemporalMetadata :: Date ( unit) => Ok ( TemporalJiff :: Date (
6667 jiff:: civil:: Date :: new ( 1970 , 1 , 1 ) ?. checked_add ( unit. to_jiff_span ( v) ?) ?,
6768 ) ) ,
68- TemporalMetadata :: Timestamp ( TimestampOptions { unit, tz } ) => match tz {
69+ TemporalMetadata :: Timestamp ( ( unit, tz) ) => match tz {
6970 None => Ok ( TemporalJiff :: Unzoned (
7071 jiff:: civil:: DateTime :: new ( 1970 , 1 , 1 , 0 , 0 , 0 , 0 ) ?
7172 . checked_add ( unit. to_jiff_span ( v) ?) ?,
0 commit comments