我有一个功能
makeMarks: (first, nextIncrement, classifier) ->
results = new Array()
t = first(@minT)
while t<=@maxT
mark =
t: t
x: this.tToX(t)
class: classifier(t)
results.push(mark)
t = nextIncrement(t)
results
这个函数适用于以下两个函数作为参数
# parameters for hour tickmarks
@firstHour = (t) ->
msPerHour = 1000*60*60
Math.floor(t / msPerHour) * msPerHour
@nextHour = (currentHour) ->
msPerHour = 1000*60*60
currentHour + msPerHour
这样称呼
marks = markMaker.makeMarks( @firstMonth, @nextMonth, @classifier)
现在问题:
# parameters for month tickmarks
@firstMonth = (minT) ->
msPerDay = 1000*60*60*24
t = Math.floor(minT/msPerDay) * msPerDay
d = new Date(t)
while(d.getDate() isnt 0)
t += msPerDay
d.setTime(t)
t
@nextMonth = (currentMonth) ->
msPerDay = 1000*60*60*24
t = currentMonth + msPerDay
d = new Date(t)
while(d.getDate() isnt 0)
t += msPerDay
d.setTime(t)
t
小时代码工作正常,但月份代码似乎没有终止。
答案 0 :(得分:2)
getDate函数永远不会返回0.它的最小值是1,它的最大值是31.如果你正在寻找超出该范围的任何东西,那就等了很长时间没有来的火车。