diff options
author | Jonathan Bernard <jdb@jdb-labs.com> | 2016-10-21 16:58:59 -0500 |
---|---|---|
committer | Jonathan Bernard <jdb@jdb-labs.com> | 2016-10-21 17:06:36 -0500 |
commit | b7232bd425806a64ac0879291f0df06bc1bee1b3 (patch) | |
tree | 2d63577dea6f921c7c13c641db5a80047101f0f0 /tests/stdlib | |
parent | 7c22c03876d3eb268d0d0fcc6c5c466f1a09fad8 (diff) | |
download | Nim-b7232bd425806a64ac0879291f0df06bc1bee1b3.tar.gz |
Fix #4922, bug in times.parse, mishandling DST.
Diffstat (limited to 'tests/stdlib')
-rw-r--r-- | tests/stdlib/ttime.nim | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/stdlib/ttime.nim b/tests/stdlib/ttime.nim index b3103b412..065009535 100644 --- a/tests/stdlib/ttime.nim +++ b/tests/stdlib/ttime.nim @@ -148,3 +148,19 @@ doAssert milliseconds(1000 * 60 * 60 * 24) == days(1) doAssert seconds(60 * 60) == hours(1) doAssert seconds(60 * 60 * 24) == days(1) doAssert seconds(60 * 60 + 65) == (hours(1) + minutes(1) + seconds(5)) + +# Bug with parse not setting DST properly if the current local DST differs from +# the date being parsed. Need to test parse dates both in and out of DST. We +# are testing that be relying on the fact that tranforming a TimeInfo to a Time +# and back again will correctly set the DST value. With the incorrect parse +# behavior this will introduce a one hour offset from the named time and the +# parsed time if the DST value differs between the current time and the date we +# are parsing. +# +# Unfortunately these tests depend on the locale of the system in which they +# are run. They will not be meaningful when run in a locale without DST. They +# also assume that Jan. 1 and Jun. 1 will have differing isDST values. +let dstT1 = parse("2016-01-01 00:00:00", "yyyy-MM-dd HH:mm:ss") +let dstT2 = parse("2016-06-01 00:00:00", "yyyy-MM-dd HH:mm:ss") +doAssert dstT1 == getLocalTime(toTime(dstT1)) +doAssert dstT2 == getLocalTime(toTime(dstT2)) |