diff --git a/morris.coffee b/morris.coffee index 206c188..40a847e 100644 --- a/morris.coffee +++ b/morris.coffee @@ -296,10 +296,13 @@ class Morris.Line year = parseInt(p[1], 10); y1 = new Date(year, 0, 1); y2 = new Date(year+1, 0, 1); + # first thursday in year (ISO 8601 standard) if y1.getDay() isnt 4 y1.setMonth(0, 1 + ((4 - y1.getDay()) + 7) % 7); + # first thursday in following year if y2.getDay() isnt 4 y2.setMonth(0, 1 + ((4 - y2.getDay()) + 7) % 7); + # Number of weeks between thursdays weeks = 1 + Math.ceil((y2 - y1) / 604800000); parseInt(p[1], 10) + (parseInt(p[2], 10) - 1) / weeks; else if n