0

在图书馆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似乎相反。

文档中指出:

# 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但结果似乎不同。另外,这些函数何时返回以及何时等于开始?有什么区别?

注意:我希望这些函数返回包含开始和结束参数的天、月、年数组

4

1 回答 1

0

正如这里清楚地解释的那样,行为实际上是一致的。两者day.rangemonth.range旨在返回startend参数之间的每日和每月边界。

于 2013-10-22T21:34:51.623 回答