Replace chrono dependency by time
This commit is contained in:
parent
4e014168b4
commit
8bc7af0d3f
11 changed files with 76 additions and 76 deletions
|
|
@ -8,9 +8,9 @@
|
|||
|
||||
use std::fmt;
|
||||
|
||||
use chrono::{DateTime, TimeZone, Utc};
|
||||
use serde::{de, ser, Deserialize, Serialize};
|
||||
use serde_json::Value;
|
||||
use time::OffsetDateTime;
|
||||
|
||||
/// Describes an account and its preferred name.
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
|
|
@ -331,15 +331,11 @@ impl<'de> Deserialize<'de> for Snowflake {
|
|||
/// Time is specified as a signed 64-bit integer, giving the number of seconds
|
||||
/// since the Unix Epoch.
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub struct Time(#[serde(with = "chrono::serde::ts_seconds")] pub DateTime<Utc>);
|
||||
pub struct Time(#[serde(with = "time::serde::timestamp")] pub OffsetDateTime);
|
||||
|
||||
impl Time {
|
||||
pub fn new(timestamp: i64) -> Self {
|
||||
Self(Utc.timestamp(timestamp, 0))
|
||||
}
|
||||
|
||||
pub fn now() -> Self {
|
||||
Self::new(Utc::now().timestamp())
|
||||
Self(OffsetDateTime::now_utc().replace_millisecond(0).unwrap())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,11 +3,11 @@ use std::sync::Arc;
|
|||
use std::time::Duration;
|
||||
|
||||
use anyhow::bail;
|
||||
use chrono::Utc;
|
||||
use log::{error, info, warn};
|
||||
use parking_lot::Mutex;
|
||||
use time::OffsetDateTime;
|
||||
use tokio::sync::{mpsc, oneshot};
|
||||
use tokio::{select, task, time};
|
||||
use tokio::{select, task};
|
||||
use tokio_tungstenite::tungstenite;
|
||||
|
||||
use crate::ui::UiEvent;
|
||||
|
|
@ -82,7 +82,7 @@ impl State {
|
|||
} else {
|
||||
info!("e&{}: could not connect", name);
|
||||
}
|
||||
time::sleep(Duration::from_secs(5)).await; // TODO Make configurable
|
||||
tokio::time::sleep(Duration::from_secs(5)).await; // TODO Make configurable
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -103,7 +103,7 @@ impl State {
|
|||
|
||||
async fn regularly_request_logs(event_tx: &mpsc::UnboundedSender<Event>) {
|
||||
loop {
|
||||
time::sleep(Duration::from_secs(2)).await; // TODO Make configurable
|
||||
tokio::time::sleep(Duration::from_secs(2)).await; // TODO Make configurable
|
||||
let _ = event_tx.send(Event::RequestLogs);
|
||||
}
|
||||
}
|
||||
|
|
@ -171,7 +171,7 @@ impl State {
|
|||
}
|
||||
Data::SnapshotEvent(d) => {
|
||||
info!("e&{}: successfully joined", self.name);
|
||||
self.vault.join(Utc::now());
|
||||
self.vault.join(OffsetDateTime::now_utc());
|
||||
self.last_msg_id = Some(d.log.last().map(|m| m.id));
|
||||
self.vault.add_messages(d.log, None);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue