refactor: switch from chrono to jiff

This commit is contained in:
Robert Perce 2026-04-03 11:54:36 -05:00
parent 79a054ab40
commit 3ffdf8f0d7
12 changed files with 205 additions and 161 deletions

View file

@ -1,4 +1,4 @@
use chrono::{DateTime, NaiveDate, Utc};
use jiff::{Timestamp, civil};
use sqlx::sqlite::SqlitePool;
use std::str::FromStr;
@ -18,7 +18,7 @@ struct RawContact {
pub struct Contact {
pub id: DbId,
pub birthday: Option<Birthday>,
pub manually_freshened_at: Option<DateTime<Utc>>,
pub manually_freshened_at: Option<Timestamp>,
pub lives_with: String,
}
@ -31,8 +31,7 @@ impl Into<Contact> for RawContact {
.and_then(|s| Birthday::from_str(s.as_ref()).ok()),
manually_freshened_at: self
.manually_freshened_at
.and_then(|str| DateTime::parse_from_str(str.as_ref(), "%+").ok())
.map(|d| d.to_utc()),
.and_then(|str| str.parse::<Timestamp>().ok()),
lives_with: self.lives_with,
}
}
@ -50,7 +49,7 @@ struct RawHydratedContact {
#[derive(Clone, Debug)]
pub struct HydratedContact {
pub contact: Contact,
pub last_mention_date: Option<NaiveDate>,
pub last_mention_date: Option<civil::Date>,
pub names: Vec<String>,
}
@ -71,7 +70,7 @@ impl Into<HydratedContact> for RawHydratedContact {
.collect::<Vec<String>>(),
last_mention_date: self
.last_mention_date
.and_then(|str| NaiveDate::from_str(str.as_ref()).ok()),
.and_then(|str| str.parse::<civil::Date>().ok()),
}
}
}