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.
This commit is contained in:
Damien Elmes 2022-04-27 16:27:13 +10:00
parent 308c663233
commit a4dfad565d
2 changed files with 3 additions and 0 deletions

View file

@ -27,6 +27,7 @@ pub(super) struct ExchangeData {
pub(super) deck_configs: Vec<DeckConfig>, pub(super) deck_configs: Vec<DeckConfig>,
pub(super) media_paths: HashSet<PathBuf>, pub(super) media_paths: HashSet<PathBuf>,
pub(super) days_elapsed: u32, pub(super) days_elapsed: u32,
pub(super) creation_utc_offset: Option<i32>,
} }
impl ExchangeData { impl ExchangeData {
@ -37,6 +38,7 @@ impl ExchangeData {
with_scheduling: bool, with_scheduling: bool,
) -> Result<()> { ) -> Result<()> {
self.days_elapsed = col.timing_today()?.days_elapsed; self.days_elapsed = col.timing_today()?.days_elapsed;
self.creation_utc_offset = col.get_creation_utc_offset();
self.notes = col.gather_notes(search)?; self.notes = col.gather_notes(search)?;
self.cards = col.gather_cards()?; self.cards = col.gather_cards()?;
self.decks = col.gather_decks()?; self.decks = col.gather_decks()?;

View file

@ -88,6 +88,7 @@ impl Collection {
let mut temp_col = Collection::new_minimal(path)?; let mut temp_col = Collection::new_minimal(path)?;
temp_col.insert_data(&data)?; temp_col.insert_data(&data)?;
temp_col.set_creation_stamp(self.storage.creation_stamp()?)?; 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))?; temp_col.close(Some(SchemaVersion::V11))?;
Ok(data) Ok(data)