Prosjekt

Generell

Profil

Oversikt

Project information

The solution seemed easier than I first thought, as it turned out that the python date object already had a .isocalendar()-method that returns a tuple with year, week and weekday according to the ISO 8601 standard. However the oposite direction was not implemented, but as you see in source:trunk/py8601.py@5#L90 it is not that hard at all. As each week is of a fixed size, we just need to establish a reference, say January 1st and then add or substract the correct ammount of days.

Problem description

As outlined in October 1996 there is no formatting codes to scanf/printf that implements the week/date conversion as described in ISO 8601. AFAIK the status there is the same as it were in October 1996.

The first week of the ISO calendar year can begin as late as 4 January and as early as 29 December of the previous year. Likewise, the last week of the ISO calendar year can end as early as 28 December and as late as 3 January of the following year. Examples of these extreme cases in the near future are:

December 2008 January 2009
22 23 24 25 26 27 28 29 30 31 1 2 3 4 5 6 7 8 9 10 11
Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su
ISO week 52 (2008) ISO week 1 (2009) ISO week 2 (2009)
December 2009 January 2010
21 22 23 24 25 26 27 28 29 30 31 1 2 3 4 5 6 7 8 9 10
Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su
ISO week 52 (2009) ISO week 53 (2009) ISO week 1 (2010)

Source: The Mathematics of the ISO 8601 Calendar as visited 2007-01-31

We need a class that can handle conversion between ISO weeks and gregorian dates.

Similar projects

I have tried to search google for similar projects, please add links here if you know such projects

Download

License

As the solution was so trivial I've decided to release the code in the public domain. You are hereby granted the right to do anything you want with the code. However the code is provided ASIS and without any warranties. Before using the code you will have to review it and decide whether it is appropriate, good enough and sufficient to fit in to your program/solve the problem you have at hand. By incorporating this algorithm and/or code into your own work, or using the code as it is, you accept the keep the author free for any responsibility, either from claims by yourself, your employer or any third party.

Location

Please download directly from the source control management system source:/trunk

svn co https://dev.interhost.no/svn/py8601/trunk py8601

Related information

Medlemmer

Developer: Christian Skarby