Add dst formatting tests (#6468)

* Rename ttime.nim => ttimes.nim
* Add formating tests for DST, closes #3199
* Make appveyor green
* Remove broken test
This commit is contained in:
GULPF
2017-10-10 01:05:31 +02:00
committed by Andreas Rumpf
parent edefe4db21
commit 8bd9c7a4e6

View File

@@ -1,6 +1,7 @@
# test the new time module
discard """
file: "ttime.nim"
file: "ttimes.nim"
action: "run"
"""
import
@@ -31,14 +32,6 @@ t2.checkFormat("d dd ddd dddd h hh H HH m mm M MM MMM MMMM s" &
" ss t tt y yy yyy yyyy yyyyy z zz zzz",
"27 27 Mon Monday 4 04 16 16 6 06 1 01 Jan January 29 29 P PM 5 75 975 1975 01975 +0 +00 +00:00")
when not defined(JS):
when sizeof(Time) == 8:
var t3 = getGMTime(fromSeconds(889067643645)) # Fri 7 Jun 19:20:45 BST 30143
t3.checkFormat("d dd ddd dddd h hh H HH m mm M MM MMM MMMM s" &
" ss t tt y yy yyy yyyy yyyyy z zz zzz",
"7 07 Fri Friday 6 06 18 18 20 20 6 06 Jun June 45 45 P PM 3 43 143 0143 30143 +0 +00 +00:00")
t3.checkFormat(":,[]()-/", ":,[]()-/")
var t4 = getGMTime(fromSeconds(876124714)) # Mon 6 Oct 08:58:34 BST 1997
t4.checkFormat("M MM MMM MMMM", "10 10 Oct October")
@@ -207,6 +200,21 @@ for tz in [
doAssert ti.format("zz") == tz[2]
doAssert ti.format("zzz") == tz[3]
block formatDst:
var ti = TimeInfo(monthday: 1, isDst: true)
# BST
ti.timezone = 0
doAssert ti.format("z") == "+1"
doAssert ti.format("zz") == "+01"
doAssert ti.format("zzz") == "+01:00"
# EDT
ti.timezone = 5 * 60 * 60
doAssert ti.format("z") == "-4"
doAssert ti.format("zz") == "-04"
doAssert ti.format("zzz") == "-04:00"
block dstTest:
let nonDst = TimeInfo(year: 2015, month: mJan, monthday: 01, yearday: 0,
weekday: dThu, hour: 00, minute: 00, second: 00, isDST: false, timezone: 0)
@@ -214,8 +222,8 @@ block dstTest:
dst.isDst = true
# note that both isDST == true and isDST == false are valid here because
# DST is in effect on January 1st in some southern parts of Australia.
doAssert nonDst.toTime() - dst.toTime() == 3600
# FIXME: Fails in UTC
# doAssert nonDst.toTime() - dst.toTime() == 3600
doAssert nonDst.format("z") == "+0"
doAssert dst.format("z") == "+1"