Allow timestamps to be a day ahead
https://github.com/ankitects/anki/issues/1895#issuecomment-1374574230
This commit is contained in:
parent
4e92c29815
commit
07fd88ddea
@ -123,14 +123,14 @@ impl ExchangeData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn check_ids(&self) -> Result<()> {
|
fn check_ids(&self) -> Result<()> {
|
||||||
let now = TimestampMillis::now().0;
|
let tomorrow = TimestampMillis::now().adding_secs(86_400).0;
|
||||||
if self
|
if self
|
||||||
.cards
|
.cards
|
||||||
.iter()
|
.iter()
|
||||||
.map(|card| card.id.0)
|
.map(|card| card.id.0)
|
||||||
.chain(self.notes.iter().map(|note| note.id.0))
|
.chain(self.notes.iter().map(|note| note.id.0))
|
||||||
.chain(self.revlog.iter().map(|entry| entry.id.0))
|
.chain(self.revlog.iter().map(|entry| entry.id.0))
|
||||||
.any(|timestamp| timestamp > now)
|
.any(|timestamp| timestamp > tomorrow)
|
||||||
{
|
{
|
||||||
Err(AnkiError::InvalidId)
|
Err(AnkiError::InvalidId)
|
||||||
} else {
|
} else {
|
||||||
|
@ -80,6 +80,10 @@ impl TimestampMillis {
|
|||||||
pub fn as_secs(self) -> TimestampSecs {
|
pub fn as_secs(self) -> TimestampSecs {
|
||||||
TimestampSecs(self.0 / 1000)
|
TimestampSecs(self.0 / 1000)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn adding_secs(self, secs: i64) -> Self {
|
||||||
|
Self(self.0 + secs * 1000)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn elapsed() -> time::Duration {
|
fn elapsed() -> time::Duration {
|
||||||
|
Loading…
Reference in New Issue
Block a user