US Week Numbers - USian Advice Needed

John Layt johnlayt at googlemail.com
Sat May 7 10:32:06 BST 2011


On Friday 06 May 2011 03:48:30 Gary Greene wrote:
> On 5 May 2011, at 12:24 AM, John Layt wrote:
> > So consensus seems to be Week 1 starts on the first Sunday, the question
> > then is what week number do the days before that receive, Week 0 or Week
> > 52/53 of the previous year?
> 
> Normally, that's just 52/53, since it's a continuance of the week started
> in the previous year.

OK, I've done that as the 'standard' US week, although the POSIX standard
uses the Week 0 variation.  I've also done the other other schemes as well as 
they are just variations on the calculation using different variables:

enum WeekNumberSystem {
    DefaultWeekNumber = -1, /**< The system locale default */
    IsoWeekNumber     =  0, /**< ISO Week Number */
    FirstFullWeek     =  1, /**< Week 1 starts on the first Week Start Day
                                 in year ends after 7 days */
    FirstPartialWeek  =  2, /**< Week 1 starts Jan 1st ends day before 
                                 first Week Start Day in year */
    SimpleWeek        =  3  /**< Week 1 starts Jan 1st ends after 7 days */
};

The FirstFullWeek and FirstPartialWeek use the value of 
KLocale::weekStartDay() to determine what day starts the week, this gives 
greater flexibility and doesn't tie support to just the USA.

Henry: Yes, all documented in the API, KCM and code.  It's set via an enum so 
more variations can be added later.  Up to now we have only supported the ISO 
standard weeks, but there's a wish for support for the US system, and we need 
it and the other variations for proper integration with Windows/Mac 
localisation systems and possibly for .xls macros (ugh).

Cheers!

John.




More information about the kde-core-devel mailing list