1
- use chrono_04:: { DateTime , NaiveDate , NaiveDateTime , NaiveTime , TimeZone , Utc } ;
1
+ use chrono_04:: { DateTime , NaiveDate , NaiveDateTime , NaiveTime , Utc } ;
2
2
use std:: fmt;
3
3
use tokio_postgres:: types:: { Date , FromSqlOwned , Timestamp } ;
4
4
use tokio_postgres:: Client ;
@@ -53,18 +53,20 @@ async fn test_with_special_naive_date_time_params() {
53
53
async fn test_date_time_params ( ) {
54
54
fn make_check ( time : & str ) -> ( Option < DateTime < Utc > > , & str ) {
55
55
(
56
- Some ( Utc . from_utc_datetime (
57
- & NaiveDateTime :: parse_from_str ( time, "'%Y-%m-%d %H:%M:%S.%f'" ) . unwrap ( ) ,
58
- ) ) ,
56
+ Some (
57
+ DateTime :: parse_from_str ( time, "'%Y-%m-%d %H:%M:%S.%f%#z'" )
58
+ . unwrap ( )
59
+ . to_utc ( ) ,
60
+ ) ,
59
61
time,
60
62
)
61
63
}
62
64
test_type (
63
65
"TIMESTAMP WITH TIME ZONE" ,
64
66
& [
65
- make_check ( "'1970-01-01 00:00:00.010000000 '" ) ,
66
- make_check ( "'1965-09-25 11:19:33.100314000 '" ) ,
67
- make_check ( "'2010-02-09 23:11:45.120200000 '" ) ,
67
+ make_check ( "'1970-01-01 00:00:00.010000000Z '" ) ,
68
+ make_check ( "'1965-09-25 11:19:33.100314000Z '" ) ,
69
+ make_check ( "'2010-02-09 23:11:45.120200000Z '" ) ,
68
70
( None , "NULL" ) ,
69
71
] ,
70
72
)
@@ -75,18 +77,20 @@ async fn test_date_time_params() {
75
77
async fn test_with_special_date_time_params ( ) {
76
78
fn make_check ( time : & str ) -> ( Timestamp < DateTime < Utc > > , & str ) {
77
79
(
78
- Timestamp :: Value ( Utc . from_utc_datetime (
79
- & NaiveDateTime :: parse_from_str ( time, "'%Y-%m-%d %H:%M:%S.%f'" ) . unwrap ( ) ,
80
- ) ) ,
80
+ Timestamp :: Value (
81
+ DateTime :: parse_from_str ( time, "'%Y-%m-%d %H:%M:%S.%f%#z'" )
82
+ . unwrap ( )
83
+ . to_utc ( ) ,
84
+ ) ,
81
85
time,
82
86
)
83
87
}
84
88
test_type (
85
89
"TIMESTAMP WITH TIME ZONE" ,
86
90
& [
87
- make_check ( "'1970-01-01 00:00:00.010000000 '" ) ,
88
- make_check ( "'1965-09-25 11:19:33.100314000 '" ) ,
89
- make_check ( "'2010-02-09 23:11:45.120200000 '" ) ,
91
+ make_check ( "'1970-01-01 00:00:00.010000000Z '" ) ,
92
+ make_check ( "'1965-09-25 11:19:33.100314000Z '" ) ,
93
+ make_check ( "'2010-02-09 23:11:45.120200000Z '" ) ,
90
94
( Timestamp :: PosInfinity , "'infinity'" ) ,
91
95
( Timestamp :: NegInfinity , "'-infinity'" ) ,
92
96
] ,
0 commit comments