Quantcast
Channel: SmartClient Forums
Viewing all articles
Browse latest Browse all 4756

Timeline wrong week number in heder

$
0
0
Tested on
Version v9.0p_2013-07-20/LGPL Development Only (2013-07-20)
and
SNAPSHOT_v10.0d_2014-02-27/LGPL Development Only

Hi...

I think there is an error in the week header title displayed in some headerLevels configurations.

Taking a simple standalone example, if we display the timeline for the current year with week/day header levels, it works right, as first week starts at "1".
Code:

isc.Timeline.create({
    startDate: new Date(2014, 0, 1, 0, 0),
    endDate: new Date(2014, 11, 31, 23, 59),
    headerLevels: [ { unit: "week" }, { unit: "day" } ]
});

Now if we change the header level to month/week for the same period, the first week of the year starts at "53" and second week is "2" (Week "1" is ommited)
Code:

isc.Timeline.create({
    startDate: new Date(2014, 0, 1, 0, 0),
    endDate: new Date(2014, 11, 31, 23, 59),
    headerLevels: [  { unit: "month" }, { unit: "week" }]
});

While debugging I've noticed that the header title in that case is built with the Date.getWeek() function, which returns wrong weeks number (according to the ISO standard). Also I've noticed that there is a new undocumented Date.getWeekNumber() function (In Snapshot v10) , which works according to the ISO standard and can be used as workaround in this way:
Code:

isc.Timeline.create({
    startDate: new Date(2014, 0, 1, 0, 0),
    endDate: new Date(2014, 11, 31, 23, 59),
    headerLevels: [  { unit: "month" },
                          { unit: "week",
                              titleFormatter: function(headerLevel, startDate, endDate, defaultValue, viewer){
                                        return startDate.getWeekNumber()[1];
                            }}]
});

Best regards....

Viewing all articles
Browse latest Browse all 4756

Trending Articles