I have a function
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
this function works great with the following two functions as parameters
# parameters for hour tickmarks
@firstHour = (t) ->
msPerHour = 1000*60*60
Math.floor(t / msPerHour) * msPerHour
@nextHour = (currentHour) ->
msPerHour = 1000*60*60
currentHour + msPerHour
when called as such
marks = markMaker.makeMarks( @firstMonth, @nextMonth, @classifier)
Now to the problem:
# 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
The hour code works fine, but the month code doesn’t seem to terminate.
The getDate function never returns 0. Its minimum value is 1 and it’s maximum value is 31. If you’re looking for anything outside that range, that’s a long wait for a train that don’t come.