File tree Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -251,6 +251,7 @@ Value PyDateTime::ToDuckValue() {
251
251
// Need to subtract the UTC offset, so we invert the interval
252
252
utc_offset = Interval::Invert (utc_offset);
253
253
timestamp = Interval::Add (timestamp, utc_offset);
254
+ return Value::TIMESTAMPTZ (timestamp);
254
255
}
255
256
return Value::TIMESTAMP (timestamp);
256
257
}
Original file line number Diff line number Diff line change @@ -69,3 +69,19 @@ def test_pandas_datetime_overflow(self):
69
69
70
70
with pytest .raises (duckdb .ConversionException ):
71
71
res = duckdb_con .execute ("select * from test" ).df ()
72
+
73
+ def test_timezone_datetime (self ):
74
+ module = pytest .importorskip ("datetime" )
75
+ timezone = module .timezone
76
+ datetime = module .datetime
77
+
78
+ con = duckdb .connect ()
79
+
80
+ dt = datetime .now (timezone .utc ).replace (microsecond = 0 )
81
+
82
+ original = dt
83
+ stringified = str (dt )
84
+
85
+ original_res = con .execute ('select ?::TIMESTAMPTZ' , [original ]).fetchone ()
86
+ stringified_res = con .execute ('select ?::TIMESTAMPTZ' , [stringified ]).fetchone ()
87
+ assert original_res == stringified_res
You can’t perform that action at this time.
0 commit comments