CalendarXP.net Support Forum Index CalendarXP.net Support
Most forums here are private and invisible to public.
 
 FAQFAQ   SearchSearch   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

How to adjust the algorithm of week numbers?

 
Post new topic   Reply to topic    CalendarXP.net Support Forum Index -> CalendarXP F.A.Q.
View previous topic :: View next topic  
Author Message
calendarxp
Site Admin


Joined: 30 Jan 2005
Posts: 409

PostPosted: Tue Feb 15, 2005 7:26 pm    Post subject: How to adjust the algorithm of week numbers? Reply with quote

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:
  1. First day of the year is in week 1.
    Code:
    function fWeekOffset(dow) {
      return 1;
    }

  2. First full week is week 1.
    Code:
    function fWeekOffset(dow) {
      return dow==0?1:0;
    }


_________________
Copyright 2003-2011 Idemfactor Solutions, Inc. All rights reserved.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    CalendarXP.net Support Forum Index -> CalendarXP F.A.Q. All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum


Copyright 2003- Idemfactor Solutions, Inc. All rights reserved.
Powered by phpBB © 2001, 2005 phpBB Group