-
Notifications
You must be signed in to change notification settings - Fork 22.9k
/
year-test.js
41 lines (35 loc) · 1.2 KB
/
year-test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
require("../env");
require("../../d3");
require("../../d3.time");
var vows = require("vows"),
assert = require("assert");
var suite = vows.describe("d3.time.year");
suite.addBatch({
"year": {
topic: function() {
return d3.time.year;
},
"returns years": function(floor) {
assert.deepEqual(floor(local(2010, 11, 31, 23, 59, 59)), local(2010, 0, 1));
assert.deepEqual(floor(local(2011, 0, 1, 0, 0, 0)), local(2011, 0, 1));
assert.deepEqual(floor(local(2011, 0, 1, 0, 0, 1)), local(2011, 0, 1));
},
"UTC": {
topic: function(floor) {
return floor.utc;
},
"returns years": function(floor) {
assert.deepEqual(floor(utc(2010, 11, 31, 23, 59, 59)), utc(2010, 0, 1));
assert.deepEqual(floor(utc(2011, 0, 1, 0, 0, 0)), utc(2011, 0, 1));
assert.deepEqual(floor(utc(2011, 0, 1, 0, 0, 1)), utc(2011, 0, 1));
}
}
}
});
function local(year, month, day, hours, minutes, seconds) {
return new Date(year, month, day, hours || 0, minutes || 0, seconds || 0);
}
function utc(year, month, day, hours, minutes, seconds) {
return new Date(Date.UTC(year, month, day, hours || 0, minutes || 0, seconds || 0));
}
suite.export(module);