Allow timestamps to be a day ahead

https://github.com/ankitects/anki/issues/1895#issuecomment-1374574230
This commit is contained in:
Damien Elmes 2023-01-09 10:04:48 +10:00
parent 4e92c29815
commit 07fd88ddea
2 changed files with 6 additions and 2 deletions

View File

@ -123,14 +123,14 @@ impl ExchangeData {
}
fn check_ids(&self) -> Result<()> {
let now = TimestampMillis::now().0;
let tomorrow = TimestampMillis::now().adding_secs(86_400).0;
if self
.cards
.iter()
.map(|card| card.id.0)
.chain(self.notes.iter().map(|note| note.id.0))
.chain(self.revlog.iter().map(|entry| entry.id.0))
.any(|timestamp| timestamp > now)
.any(|timestamp| timestamp > tomorrow)
{
Err(AnkiError::InvalidId)
} else {

View File

@ -80,6 +80,10 @@ impl TimestampMillis {
pub fn as_secs(self) -> TimestampSecs {
TimestampSecs(self.0 / 1000)
}
pub fn adding_secs(self, secs: i64) -> Self {
Self(self.0 + secs * 1000)
}
}
fn elapsed() -> time::Duration {