Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Fixchrono::DateTime<Utc> tests#1170

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
sfackler merged 1 commit intorust-postgres:masterfromallan2:chrono-test
Aug 16, 2024
Merged
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 17 additions & 13 deletionstokio-postgres/tests/test/types/chrono_04.rs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
use chrono_04::{DateTime, NaiveDate, NaiveDateTime, NaiveTime,TimeZone,Utc};
use chrono_04::{DateTime, NaiveDate, NaiveDateTime, NaiveTime, Utc};
use std::fmt;
use tokio_postgres::types::{Date, FromSqlOwned, Timestamp};
use tokio_postgres::Client;
Expand DownExpand Up@@ -53,18 +53,20 @@ async fn test_with_special_naive_date_time_params() {
async fn test_date_time_params() {
fn make_check(time: &str) -> (Option<DateTime<Utc>>, &str) {
(
Some(Utc.from_utc_datetime(
&NaiveDateTime::parse_from_str(time, "'%Y-%m-%d %H:%M:%S.%f'").unwrap(),
)),
Some(
DateTime::parse_from_str(time, "'%Y-%m-%d %H:%M:%S.%f%#z'")
.unwrap()
.to_utc(),
),
time,
)
}
test_type(
"TIMESTAMP WITH TIME ZONE",
&[
make_check("'1970-01-01 00:00:00.010000000'"),
make_check("'1965-09-25 11:19:33.100314000'"),
make_check("'2010-02-09 23:11:45.120200000'"),
make_check("'1970-01-01 00:00:00.010000000Z'"),
make_check("'1965-09-25 11:19:33.100314000Z'"),
make_check("'2010-02-09 23:11:45.120200000Z'"),
(None, "NULL"),
],
)
Expand All@@ -75,18 +77,20 @@ async fn test_date_time_params() {
async fn test_with_special_date_time_params() {
fn make_check(time: &str) -> (Timestamp<DateTime<Utc>>, &str) {
(
Timestamp::Value(Utc.from_utc_datetime(
&NaiveDateTime::parse_from_str(time, "'%Y-%m-%d %H:%M:%S.%f'").unwrap(),
)),
Timestamp::Value(
DateTime::parse_from_str(time, "'%Y-%m-%d %H:%M:%S.%f%#z'")
.unwrap()
.to_utc(),
),
time,
)
}
test_type(
"TIMESTAMP WITH TIME ZONE",
&[
make_check("'1970-01-01 00:00:00.010000000'"),
make_check("'1965-09-25 11:19:33.100314000'"),
make_check("'2010-02-09 23:11:45.120200000'"),
make_check("'1970-01-01 00:00:00.010000000Z'"),
make_check("'1965-09-25 11:19:33.100314000Z'"),
make_check("'2010-02-09 23:11:45.120200000Z'"),
(Timestamp::PosInfinity, "'infinity'"),
(Timestamp::NegInfinity, "'-infinity'"),
],
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp