Update for Nim 0.19.0, add trimNanoSec
This commit is contained in:
@ -14,34 +14,26 @@ suite "timeutils":
|
||||
test "DateTime difference":
|
||||
var t1 = getTime().local
|
||||
var t2 = t1 + 30.seconds
|
||||
check (t2 - t1) == 30.seconds
|
||||
check timeutils.`-`(t2, t1) == initDuration(seconds = 30)
|
||||
|
||||
t1 = parse("2016-10-10 09:45:00", "yyyy-MM-dd HH:mm:ss")
|
||||
t2 = parse("2016-10-11 09:45:00", "yyyy-MM-dd HH:mm:ss")
|
||||
check t2 - t1 == seconds(24 * 60 * 60)
|
||||
check timeutils.`-`(t2, t1) == initDuration(seconds = 24 * 60 * 60)
|
||||
|
||||
t2 = parse("2016-10-11 10:00:00", "yyyy-MM-dd HH:mm:ss")
|
||||
check t2 - t1 == seconds((24 * 60 + 15) * 60)
|
||||
check timeutils.`-`(t2, t1) == initDuration(seconds = (24 * 60 + 15) * 60)
|
||||
|
||||
test "DateTime comparisons":
|
||||
let t1 = getTime().local
|
||||
|
||||
check:
|
||||
t1 < t1 + 10.seconds
|
||||
not (t1 + 10.seconds < t1)
|
||||
not (t1 > t1)
|
||||
timeutils.`<`(t1, t1 + 10.seconds)
|
||||
not timeutils.`<`(t1 + 10.seconds, t1)
|
||||
not timeutils.`<`(t1, t1)
|
||||
|
||||
t1 + 10.seconds > t1
|
||||
not (t1 > t1 + 10.seconds)
|
||||
not (t1 < t1)
|
||||
|
||||
t1 + 10.seconds >= t1
|
||||
t1 >= t1
|
||||
not (t1 >= t1 + 10.seconds)
|
||||
|
||||
t1 <= t1 + 10.seconds
|
||||
t1 <= t1
|
||||
not (t1 + 10.seconds <= t1)
|
||||
timeutils.`<=`(t1, t1 + 10.seconds)
|
||||
timeutils.`<=`(t1, t1)
|
||||
not timeutils.`<=`(t1 + 10.seconds, t1)
|
||||
|
||||
t1.between(t1 - 10.seconds, t1 + 10.seconds)
|
||||
t1.between(t1, t1 + 10.seconds) # start is inclusive
|
||||
@ -49,21 +41,13 @@ suite "timeutils":
|
||||
|
||||
test "TimeInterval comparisons":
|
||||
check:
|
||||
30.seconds > 10.seconds
|
||||
not (10.seconds > 30.seconds)
|
||||
not (10.seconds > 10.seconds)
|
||||
timeutils.`<`(10.minutes, 1.hours)
|
||||
not timeutils.`<`(1.hours, 10.minutes)
|
||||
not timeutils.`<`(1.hours, 1.hours)
|
||||
|
||||
10.minutes < 1.hours
|
||||
not (1.hours < 10.minutes)
|
||||
not (1.hours < 1.hours)
|
||||
|
||||
60.seconds >= 1.minutes
|
||||
60.seconds >= 1.minutes
|
||||
not (60.seconds >= 2.minutes)
|
||||
|
||||
60.seconds <= 1.minutes
|
||||
60.seconds <= 2.minutes
|
||||
not (2.minutes <= 60.seconds)
|
||||
timeutils.`<=`(60.seconds, 1.minutes)
|
||||
timeutils.`<=`(60.seconds, 2.minutes)
|
||||
not timeutils.`<=`(2.minutes, 60.seconds)
|
||||
|
||||
test "DateTime cmp":
|
||||
let t1 = getTime().local
|
||||
|
Reference in New Issue
Block a user