@@ -163,11 +163,16 @@ main = do
163
163
assert $ DateTime .diff dt5 dt3 == Duration.Days 29.0
164
164
assert $ DateTime .diff dt1 dt3 == Duration.Days (-31.0 )
165
165
assert $ DateTime .diff dt4 dt1 == Duration .fromDuration (Duration.Days 31.0 ) <> Duration .fromDuration (Duration.Minutes 40.0 )
166
- assert $ over Duration.Days floor (DateTime .diff dt1 epochDateTime)
167
- == Duration.Days 735963.0
166
+ assert $ over Duration.Days floor (DateTime .diff dt1 epochDateTime) == Duration.Days 735963.0
168
167
169
168
-- instant -----------------------------------------------------------------
170
169
170
+ let i1 = Instant .fromDateTime dt1
171
+ let i2 = Instant .fromDateTime dt2
172
+ let i3 = Instant .fromDateTime dt3
173
+ let i4 = Instant .fromDateTime dt4
174
+ let i5 = Instant .fromDateTime dt5
175
+
171
176
log " Check that the earliest date is a valid Instant"
172
177
let bottomInstant = Instant .fromDateTime bottom
173
178
assert $ Just bottomInstant == Instant .instant (Instant .unInstant bottomInstant)
@@ -182,10 +187,19 @@ main = do
182
187
log " Check that instant/datetime conversion is bijective"
183
188
assert $ Instant .toDateTime (Instant .fromDateTime bottom) == bottom
184
189
assert $ Instant .toDateTime (Instant .fromDateTime top) == top
185
- assert $ Instant .toDateTime (Instant .fromDateTime dt1) == dt1
186
- assert $ Instant .toDateTime (Instant .fromDateTime dt2) == dt2
187
- assert $ Instant .toDateTime (Instant .fromDateTime dt3) == dt3
188
- assert $ Instant .toDateTime (Instant .fromDateTime dt4) == dt4
190
+ assert $ Instant .toDateTime i1 == dt1
191
+ assert $ Instant .toDateTime i2 == dt2
192
+ assert $ Instant .toDateTime i3 == dt3
193
+ assert $ Instant .toDateTime i4 == dt4
194
+ assert $ Instant .toDateTime i5 == dt5
195
+
196
+ log " Check that diff behaves as expected"
197
+ assert $ Instant .diff i2 i1 == Duration.Minutes 40.0
198
+ assert $ Instant .diff i1 i2 == Duration.Minutes (-40.0 )
199
+ assert $ Instant .diff i3 i1 == Duration.Days 31.0
200
+ assert $ Instant .diff i5 i3 == Duration.Days 29.0
201
+ assert $ Instant .diff i1 i3 == Duration.Days (-31.0 )
202
+ assert $ Instant .diff i4 i1 == Duration .fromDuration (Duration.Days 31.0 ) <> Duration .fromDuration (Duration.Minutes 40.0 )
189
203
190
204
log " All tests done"
191
205
0 commit comments