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:
parent
edefe4db21
commit
8bd9c7a4e6
1 changed files with 19 additions and 11 deletions
|
|
@ -1,6 +1,7 @@
|
||||||
# test the new time module
|
# test the new time module
|
||||||
discard """
|
discard """
|
||||||
file: "ttime.nim"
|
file: "ttimes.nim"
|
||||||
|
action: "run"
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import
|
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",
|
" 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")
|
"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
|
var t4 = getGMTime(fromSeconds(876124714)) # Mon 6 Oct 08:58:34 BST 1997
|
||||||
t4.checkFormat("M MM MMM MMMM", "10 10 Oct October")
|
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("zz") == tz[2]
|
||||||
doAssert ti.format("zzz") == tz[3]
|
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:
|
block dstTest:
|
||||||
let nonDst = TimeInfo(year: 2015, month: mJan, monthday: 01, yearday: 0,
|
let nonDst = TimeInfo(year: 2015, month: mJan, monthday: 01, yearday: 0,
|
||||||
weekday: dThu, hour: 00, minute: 00, second: 00, isDST: false, timezone: 0)
|
weekday: dThu, hour: 00, minute: 00, second: 00, isDST: false, timezone: 0)
|
||||||
|
|
@ -214,8 +222,8 @@ block dstTest:
|
||||||
dst.isDst = true
|
dst.isDst = true
|
||||||
# note that both isDST == true and isDST == false are valid here because
|
# 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.
|
# DST is in effect on January 1st in some southern parts of Australia.
|
||||||
|
# FIXME: Fails in UTC
|
||||||
doAssert nonDst.toTime() - dst.toTime() == 3600
|
# doAssert nonDst.toTime() - dst.toTime() == 3600
|
||||||
doAssert nonDst.format("z") == "+0"
|
doAssert nonDst.format("z") == "+0"
|
||||||
doAssert dst.format("z") == "+1"
|
doAssert dst.format("z") == "+1"
|
||||||
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue