mirror of
https://github.com/samsonjs/strftime.git
synced 2026-03-25 09:05:48 +00:00
36 lines
715 B
CoffeeScript
36 lines
715 B
CoffeeScript
|
|
assert = require 'assert'
|
|
|
|
lib = require './../lib'
|
|
|
|
|
|
# Tue, 07 Jun 2011 18:51:45 GMT
|
|
t = new Date 1307472705867
|
|
|
|
|
|
TESTS = [
|
|
|
|
["%Y", "2011", "2011"]
|
|
|
|
["%m", "06"]
|
|
["%b", "Jun", "Jun"]
|
|
["%B", "June", "June"]
|
|
|
|
["%d", null, "07"]
|
|
|
|
["%H", null, "18"]
|
|
|
|
["%M", "51", "51"]
|
|
|
|
["%S", "45", "45"]
|
|
|
|
["%s", "1307472705"]
|
|
]
|
|
|
|
for [format, expectedNonUTC, expectedUTC] in TESTS
|
|
expectedUTC or= expectedNonUTC
|
|
for [name, expected] in [['strftime', expectedNonUTC], ['strftimeUTC', expectedUTC]]
|
|
if expected
|
|
got = lib[name] format, t
|
|
assert.equal expected, got, "Error for #{name}(#{JSON.stringify(format)}, t): expected #{JSON.stringify(expected)}, got #{JSON.stringify(got)}"
|
|
|