Closed ChanManChan closed 1 month ago
Hi @ChanManChan, there is currently no way to add a chrono::Duration
/chrono::TimeDelta
directly to a bson::DateTime
. Your current approach looks reasonable. Enabling the chrono-0_4
feature flag if you have not done so already will also allow you to convert more easily between bson::DateTime
and chrono::DateTime
via the to_chrono
and from_chrono
methods.
Hi @ChanManChan, there is currently no way to add a
chrono::Duration
/chrono::TimeDelta
directly to abson::DateTime
. Your current approach looks reasonable. Enabling thechrono-0_4
feature flag if you have not done so already will also allow you to convert more easily betweenbson::DateTime
andchrono::DateTime
via theto_chrono
andfrom_chrono
methods.
Thanks for the suggestions but I think I'm sticking with my solution if you find it reasonable.
Is there a better way to add chrono::Duration to bson::DateTime without converting to chrono::DateTime?
currently I'm doing this expires_at: DateTime::from_millis(now.timestamp_millis() + duration.num_milliseconds()),