在图书馆D3
中。我发现处理日期的函数集有点不一致。例如,在页面加载D3
的控制台中执行以下4个步骤,我得到:
> start = new Date(2010, 11, 30)
Thu Dec 30 2010 00:00:00 GMT+0000 (GMT Standard Time)
> end = new Date(2011, 0, 2)
Sun Jan 02 2011 00:00:00 GMT+0000 (GMT Standard Time)
> d3.time.months(start, end, 1)
[Sat Jan 01 2011 00:00:00 GMT+0000 (GMT Standard Time)]
> d3.time.days(start, end, 1)
[Thu Dec 30 2010 00:00:00 GMT+0000 (GMT Standard Time), Fri Dec 31 2010 00:00:00 GMT+0000 (GMT Standard Time), Sat Jan 01 2011 00:00:00 GMT+0000 (GMT Standard Time)]
以上表示day.range
从第一项开始,在第二项之前结束,而month.range
似乎则相反。
在documentation中声明:
# d3.time.months(start, stop[, step])
Alias for d3.time.month.range. Returns the month boundaries (e.g., January 01)
after or equal to start and before stop. If step is specified, then every step'th
month will be returned, based on the month of the year. For example, a step of 3
will return January, April, July, etc.
after or equal to start and before stop
也提到了 time.days
,但结果似乎有所不同。此外,当这些函数在等于开始后返回时?有什么区别?
NB:我的愿望是让这些函数返回几天,几个月,几年的数组,包括两个开始和结束参数。