diff options
author | Conrad Ludgate <conradludgate@gmail.com> | 2023-09-11 09:26:05 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-09-11 09:26:05 +0100 |
commit | f90c01f702f6a98b041f766b6a1d857bc1b9afef (patch) | |
tree | 04a4755bd632abdcf398d0ce903163ed60a5a212 /atuin-client/src/sync.rs | |
parent | 2342a3392349c0ae9d742e9da9833590e6567d08 (diff) |
replace chrono with time (#806)
* replace chrono with time
* Fix test chrono usage
---------
Co-authored-by: Ellie Huxtable <ellie@elliehuxtable.com>
Diffstat (limited to 'atuin-client/src/sync.rs')
-rw-r--r-- | atuin-client/src/sync.rs | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/atuin-client/src/sync.rs b/atuin-client/src/sync.rs index 6704ad53c..439ed6d02 100644 --- a/atuin-client/src/sync.rs +++ b/atuin-client/src/sync.rs @@ -2,11 +2,11 @@ use std::collections::HashSet; use std::convert::TryInto; use std::iter::FromIterator; -use chrono::prelude::*; use eyre::Result; use atuin_common::api::AddHistoryRequest; use crypto_secretbox::Key; +use time::OffsetDateTime; use crate::{ api_client, @@ -52,12 +52,12 @@ async fn sync_download( let mut local_count = initial_local; let mut last_sync = if force { - Utc.timestamp_millis(0) + OffsetDateTime::UNIX_EPOCH } else { Settings::last_sync()? }; - let mut last_timestamp = Utc.timestamp_millis(0); + let mut last_timestamp = OffsetDateTime::UNIX_EPOCH; let host = if force { Some(String::from("")) } else { None }; @@ -74,7 +74,7 @@ async fn sync_download( .map(|h| decrypt(h, key).expect("failed to decrypt history! check your key")) .map(|mut h| { if remote_deleted.contains(h.id.as_str()) { - h.deleted_at = Some(chrono::Utc::now()); + h.deleted_at = Some(time::OffsetDateTime::now_utc()); h.command = String::from(""); } @@ -99,8 +99,8 @@ async fn sync_download( // be "lost" between syncs. In this case we need to rewind the sync // timestamps if page_last == last_timestamp { - last_timestamp = Utc.timestamp_millis(0); - last_sync -= chrono::Duration::hours(1); + last_timestamp = OffsetDateTime::UNIX_EPOCH; + last_sync -= time::Duration::hours(1); } else { last_timestamp = page_last; } @@ -142,7 +142,7 @@ async fn sync_upload( debug!("remote has {}, we have {}", remote_count, local_count); // first just try the most recent set - let mut cursor = Utc::now(); + let mut cursor = OffsetDateTime::now_utc(); while local_count > remote_count { let last = db.before(cursor, remote_status.page_size).await?; |