feat: LT for Timestamp and Duration (#8422)

This PR adds `LT` and `Decidable` `LT` instances for
`Std.Time.Timestamp` and `Std.Time.Duration`.
This commit is contained in:
Henrik Böving 2025-05-20 13:33:49 +02:00 committed by GitHub
parent 3790f8c78e
commit 8e0870beec
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 12 additions and 0 deletions

View file

@ -34,6 +34,12 @@ instance : LE Timestamp where
instance { x y : Timestamp } : Decidable (x ≤ y) :=
inferInstanceAs (Decidable (x.val ≤ y.val))
instance : LT Timestamp where
lt x y := x.val < y.val
instance { x y : Timestamp } : Decidable (x < y) :=
inferInstanceAs (Decidable (x.val < y.val))
instance : OfNat Timestamp n where
ofNat := ⟨OfNat.ofNat n⟩

View file

@ -156,6 +156,12 @@ instance : LE Duration where
instance {x y : Duration} : Decidable (x ≤ y) :=
inferInstanceAs (Decidable (x.toNanoseconds ≤ y.toNanoseconds))
instance : LT Duration where
lt d1 d2 := d1.toNanoseconds < d2.toNanoseconds
instance {x y : Duration} : Decidable (x < y) :=
inferInstanceAs (Decidable (x.toNanoseconds < y.toNanoseconds))
/--
Converts a `Duration` to a `Minute.Offset`
-/