mirror of
https://github.com/element-hq/synapse.git
synced 2026-06-02 12:54:48 +00:00
Handle the case of a very large duration
This commit is contained in:
@@ -38,7 +38,10 @@ impl SynapseDuration {
|
||||
/// For now we only need to create durations from milliseconds.
|
||||
pub const fn from_milliseconds(milliseconds: u64) -> Self {
|
||||
Self {
|
||||
microseconds: milliseconds * 1_000,
|
||||
// We saturate at u64::MAX microseconds to avoid overflow, which
|
||||
// means that the maximum duration we can represent is approximately
|
||||
// 584,942 years.
|
||||
microseconds: milliseconds.saturating_mul(1_000),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user