replace chrono with time (#806)

* replace chrono with time

* Fix test chrono usage

---------

Co-authored-by: Ellie Huxtable <ellie@elliehuxtable.com>
This commit is contained in:
Conrad Ludgate
2023-09-11 09:26:05 +01:00
committed by GitHub
parent 2342a33923
commit f90c01f702
35 changed files with 358 additions and 385 deletions

View File

@ -14,7 +14,7 @@ atuin-common = { path = "../atuin-common", version = "16.0.0" }
atuin-server-database = { path = "../atuin-server-database", version = "16.0.0" }
tracing = "0.1"
chrono = { workspace = true }
time = { workspace = true }
serde = { workspace = true }
sqlx = { workspace = true }
async-trait = { workspace = true }

View File

@ -7,6 +7,7 @@ use serde::{Deserialize, Serialize};
use sqlx::postgres::PgPoolOptions;
use sqlx::Row;
use time::{OffsetDateTime, PrimitiveDateTime};
use tracing::instrument;
use wrappers::{DbHistory, DbRecord, DbSession, DbUser};
@ -139,7 +140,7 @@ impl Database for Postgres {
)
.bind(user.id)
.bind(id)
.bind(chrono::Utc::now().naive_utc())
.bind(OffsetDateTime::now_utc())
.fetch_all(&self.pool)
.await
.map_err(fix_error)?;
@ -175,8 +176,8 @@ impl Database for Postgres {
async fn count_history_range(
&self,
user: &User,
start: chrono::NaiveDateTime,
end: chrono::NaiveDateTime,
start: PrimitiveDateTime,
end: PrimitiveDateTime,
) -> DbResult<i64> {
let res: (i64,) = sqlx::query_as(
"select count(1) from history
@ -198,8 +199,8 @@ impl Database for Postgres {
async fn list_history(
&self,
user: &User,
created_after: chrono::NaiveDateTime,
since: chrono::NaiveDateTime,
created_after: OffsetDateTime,
since: OffsetDateTime,
host: &str,
page_size: i64,
) -> DbResult<Vec<History>> {