mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-28 02:03:59 +00:00
fix https://github.com/nim-lang/RFCs/issues/211: var a: DateTime compiles and is usable (#14002) [backport:1.2]
* fix https://github.com/nim-lang/RFCs/issues/211: `var a: DateTime` works * assertValidDate checks for sentinel month
This commit is contained in:
@@ -614,6 +614,21 @@ suite "ttimes":
|
||||
doAssert x + between(x, y) == y
|
||||
doAssert between(x, y) == 1.months + 1.weeks
|
||||
|
||||
test "default DateTime": # https://github.com/nim-lang/RFCs/issues/211
|
||||
var num = 0
|
||||
for ai in Month: num.inc
|
||||
doAssert num == 12
|
||||
|
||||
var a: DateTime
|
||||
doAssert a == DateTime.default
|
||||
doAssert ($a).len > 0 # no crash
|
||||
doAssert a.month.Month.ord == 0
|
||||
doAssert a.month.Month == cast[Month](0)
|
||||
doAssert a.monthday == 0
|
||||
|
||||
doAssertRaises(AssertionError): discard getDayOfWeek(a.monthday, a.month, a.year)
|
||||
doAssertRaises(AssertionError): discard a.toTime
|
||||
|
||||
test "inX procs":
|
||||
doAssert initDuration(seconds = 1).inSeconds == 1
|
||||
doAssert initDuration(seconds = -1).inSeconds == -1
|
||||
|
||||
Reference in New Issue
Block a user