calendarxp Site Admin
Joined: 30 Jan 2005 Posts: 409
|
Posted: Tue Feb 15, 2005 7:26 pm Post subject: How to adjust the algorithm of week numbers? |
|
|
The default algorithm employed is ISO8601 standard, which means Jan 1st will belong to the last week of last year if it falls in the last 3 days of a week. To make it more flexible, now you may re-define the fWeekOffset function in plugins.js to return an offset of 1 or 0, which will be used to adjust the week number.
The day-of-week location of the first day of year (January 1st) will be passed in as the only parameter. This location is a number of between 0 and 6 that denotes one of the 7 day-of-week columns of the calendar from left to right. e.g. if you want Jan 1st should be taken into the week no.1 of the current year only when it falls between Monday-Friday, and the giFirstDOW is set to 0 (means week column 0 is Sunday), then you should add the following code to plugins.js:
Code: | function fWeekOffset(dow) {
return 1<=dow&&dow<=5?1:0;
} |
If the giFirstDOW is set to 1 (means week column 0 is Monday), then the following code should be used instead (because Monday - Friday is 0 - 4 now):
Code: | function fWeekOffset(dow) {
return dow<=4?1:0;
} |
Following are 2 other interesting examples:
- First day of the year is in week 1.
Code: | function fWeekOffset(dow) {
return 1;
} |
First full week is week 1.
Code: | function fWeekOffset(dow) {
return dow==0?1:0;
} |
_________________ Copyright 2003-2011 Idemfactor Solutions, Inc. All rights reserved. |
|