Skip to content

Commit 8e0870b

Browse files
authored
feat: LT for Timestamp and Duration (#8422)
This PR adds `LT` and `Decidable` `LT` instances for `Std.Time.Timestamp` and `Std.Time.Duration`.
1 parent 3790f8c commit 8e0870b

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

src/Std/Time/DateTime/Timestamp.lean

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@ instance : LE Timestamp where
3434
instance { x y : Timestamp } : Decidable (x ≤ y) :=
3535
inferInstanceAs (Decidable (x.val ≤ y.val))
3636

37+
instance : LT Timestamp where
38+
lt x y := x.val < y.val
39+
40+
instance { x y : Timestamp } : Decidable (x < y) :=
41+
inferInstanceAs (Decidable (x.val < y.val))
42+
3743
instance : OfNat Timestamp n where
3844
ofNat := ⟨OfNat.ofNat n⟩
3945

src/Std/Time/Duration.lean

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,12 @@ instance : LE Duration where
156156
instance {x y : Duration} : Decidable (x ≤ y) :=
157157
inferInstanceAs (Decidable (x.toNanoseconds ≤ y.toNanoseconds))
158158

159+
instance : LT Duration where
160+
lt d1 d2 := d1.toNanoseconds < d2.toNanoseconds
161+
162+
instance {x y : Duration} : Decidable (x < y) :=
163+
inferInstanceAs (Decidable (x.toNanoseconds < y.toNanoseconds))
164+
159165
/--
160166
Converts a `Duration` to a `Minute.Offset`
161167
-/

0 commit comments

Comments
 (0)