I’m trying to get the difference between two Timestamp typed variables.
First tried this:
let now:Timestamp = ctx.metadata().slot_time();;
let time_since_last_withdrawal = now - host.state().last_withdrawal_time;
if time_since_last_withdrawal < host.state().time_interval {
return Err(Error::WithdrawalTimeNotReached);
}
And got this error: cannot subtract concordium_std::Timestamp from `concordium_std::Timestamp
Below is another attempt:
let now:Timestamp = ctx.metadata().slot_time();;
let time_since_last_withdrawal = now.duration_since(host.state().last_withdrawal_time);
if time_since_last_withdrawal < Some(host.state().time_interval.duration_between(host.state().time_interval)) {
return Err(Error::WithdrawalTimeNotReached);
}
And another error: mismatched types expected enum Option<concordium_std::Duration>
** found struct `concordium_std::Timestamp**