From a4dfad565d51f8d291d1044178834ec3e1b5637b Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Wed, 27 Apr 2022 16:27:13 +1000 Subject: [PATCH] Fix a corner-case where due dates were shifted by a day This issue existed in the old Python code as well. We need to include the user's UTC offset in the exported file, or days_elapsed falls back on the v1 cutoff calculation, which may be a day earlier or later than the v2 calculation. --- rslib/src/import_export/gather.rs | 2 ++ rslib/src/import_export/package/apkg/export.rs | 1 + 2 files changed, 3 insertions(+) diff --git a/rslib/src/import_export/gather.rs b/rslib/src/import_export/gather.rs index 0dc93f9cb..70ab11789 100644 --- a/rslib/src/import_export/gather.rs +++ b/rslib/src/import_export/gather.rs @@ -27,6 +27,7 @@ pub(super) struct ExchangeData { pub(super) deck_configs: Vec, pub(super) media_paths: HashSet, pub(super) days_elapsed: u32, + pub(super) creation_utc_offset: Option, } impl ExchangeData { @@ -37,6 +38,7 @@ impl ExchangeData { with_scheduling: bool, ) -> Result<()> { self.days_elapsed = col.timing_today()?.days_elapsed; + self.creation_utc_offset = col.get_creation_utc_offset(); self.notes = col.gather_notes(search)?; self.cards = col.gather_cards()?; self.decks = col.gather_decks()?; diff --git a/rslib/src/import_export/package/apkg/export.rs b/rslib/src/import_export/package/apkg/export.rs index c24bded2b..e1c896622 100644 --- a/rslib/src/import_export/package/apkg/export.rs +++ b/rslib/src/import_export/package/apkg/export.rs @@ -88,6 +88,7 @@ impl Collection { let mut temp_col = Collection::new_minimal(path)?; temp_col.insert_data(&data)?; temp_col.set_creation_stamp(self.storage.creation_stamp()?)?; + temp_col.set_creation_utc_offset(data.creation_utc_offset)?; temp_col.close(Some(SchemaVersion::V11))?; Ok(data)