Robotic Tendencies
The personal blog of Robert McQueen

November 21, 2005

When exactly is week 1 of 2006?

According to Jeff, I’ve become a smelly Nokia contractor (the reason he stayed with Luis instead of at Mako’s place in Boston, although I’m sure he was referring to Rob Taylor causing the smell). Part of this entails exchanging project schedules with various managers, where time is often talked about in terms of numbered weeks of the year, like: Foo task will be completed by week 42 of 2005. We ran into some problems with varying definitions of these numbers when exchanging schedules with people running on different platforms. Then we realised that even the software we’re using seems to have different ideas about what’s going on too…

  • Outlook and Evolution seem to agree, and define the week as starting on Monday, and the first day of the year is always week 1, even if this results in a truncated week. Hence, week 1 of 2006 starts and ends on Sunday 1st January, and then week 2 begins on Monday 2nd, etc. It’s my belief that this is the correct behaviour as defined by some ISO standard somewhere which governs week numbers.
  • GtkCalendar gets the week number correct, in that the first day of the year is always in week 1, but varies its definition of the first day of the week depending on your locale. This is presumably so that the display of the weeks is correct, but using it to number the weeks results in bogus week numbers. For me in LOCALE=en_GB it claims that week 1 of 2006 starts on Sunday 1st January, and ends on Saturday 7th January, making my week numbers one lower than the rest of the world.
  • Planner uses GtkCalendar for inputting dates, so gets it wrong there as described, but seems to get it wrong in its Gantt chart view in a different way. It has the week starting on Monday, but claims that January 1st 2006 is the last day of week 52 of 2005. This results in week numbers that, match those GtkCalendar give me on weekdays, but differ over weekends, and are still totally bogus when I try and talk about project plans with my managers.

The result is a whole world of pain, and at best causes extreme confusion when we provide documents referring to both dates and week numbers which are inconsistent with each other in their minds, and at worst makes our managers think we’ll have things done a week sooner than we do. I’m not using Evolution at the moment for calendaring stuff, so I can manage if I remember to add one to all my 2006 week numbers when interacting with managers based on GtkCalendar and Planner, but this all seems to be horribly broken. I really don’t want to have to do this for the whole year.

posted by ramcq @ 5:06 pm
Comments (10) .:. Trackback .:. Permalink

10 responses to “When exactly is week 1 of 2006?”

  1. osma says:

    You’re slightly off in all of those guesses. According to the ISO 8601 standard, the first week of the year is the week in which the first Thursday is. That is, if Jan 1st is Friday or Saturday, that’s week 53 of the previous year.

    The standard also defines that weeks begin on Monday, but that is actually independent of the week number calculation, which is tied to Thursdays only. The logic behind is that thursday is the middle point of the week, so it makes sense starting the count from there. This is almost true even if you start your weeks on a Sunday.

    Not sure which one of the programs you refer to is correctly calculating the week numbers, but that’s the official method – and given you’re interested in the week numbers because of Nokia, more importantly that’s how Nokia calculates them in their phones.

  2. Frederik says:

    ISO 8601 defines week 1 as the first week with the majority of its days in the new year.
    Weeks start on monday.

  3. When in doubt, turn to Markus Kuhn’s summary of the international standard date and time notation:

    In commercial and industrial applications (delivery times, production plans, etc.), especially in Europe, it is often required to refer to a week of a year. Week 01 of a year is per definition the first week that has the Thursday in this year, which is equivalent to the week that contains the fourth day of January. In other words, the first week of a new year is the week that has the majority of its days in the new year. Week 01 might also contain days from the previous year and the week before week 01 of a year is the last week (52 or 53) of the previous year even if it contains days from the new year. A week starts with Monday (day 1) and ends with Sunday (day 7). For example, the first week of the year 1997 lasts from 1996-12-30 to 1997-01-05 and can be written in standard notation as

    1997-W01

    or

    1997W01

    The week notation can also be extended by a number indicating the day of the week. For example, the day 1996-12-31, which is the Tuesday (day 2) of the first week of 1997, can also be written as

    1997-W01-2

    or

    1997W012

    for applications like industrial planning where many things like shift rotations are organized per week and knowing the week number and the day of the week is more handy than knowing the day of the month.

    An abbreviated version of the year and week number like

    1995W05

    is sometimes useful as a compact code printed on a product that indicates when it has been manufactured.

    Note:

    The ISO standard avoids explicitly stating the possible range of week numbers, but this can easily be deduced from the definition. Possible ISO week numbers are in the range 01 to 53. A year always has a week 52. (There is one historic exception: the year in which the Gregorian calendar was introduced had less than 365 days and less than 52 weeks.)

    Proof:

    Per definition, the first week of a year is W01 and consequently days before week W01 belong to the previous year and so there is no week with lower numbers. Considering the highest possible week number, the worst case is a leap year like 1976 that starts with a Thursday, because this keeps the highest possible number of days of W01 in the previous year, i.e. 3 days. In this case, the Sunday of W52 of the worst case year is day number 4+51*7=361 and 361-366=5 days of W53 belong still to this year, which guarantees that in the worst case year day 4 (Thursday) of W53 is not yet in the next year, so a week number 53 is possible. For example, the 53 weeks of the worst case year 1976 started with 1975-12-29 = 1976-W01-1 and ended with 1977-01-02 = 1976-W53-7. On the other hand, considering the lowest number of the last week of a year, the worst case is a non-leap year like 1999 that starts with a Friday, which ensures that the first three days of the year belong to the last week of the previous year. In this case, the Sunday of week 52 would be day number 3+52*7=367, i.e. only the last 367-365=2 days of the W52 reach into the next year and consequently, even a worst case year like 1999 has a week W52 including the days 1999-12-27 to 2000-01-02. q.e.d.

    There was a calendar of ISO weeks but it doesn’t seem to be updated anymore.

  4. Daniel Smertnig says:

    Actually ISO 8601 defines a week to be in the year that its Thursday is in, i.e. week #1 is the week containing the first Thursday in the new year. This ensures that all weeks are full weeks and that every week can be uniquely identified (under some definitions week 53 of one year can be the same as week 1 of the following year). Especially when planning with weeks this makes a lot of sense.

    A good overview of the ISO calendar can be found at http://www.phys.uu.nl/~vgent/calendar/isocalendar.htm.

    Btw, at least Evolution 2.2 and the gnome clock applet seem to be using this definition of week numbers
    (I’m using LANG=en_US with
    LC_TIME=de_AT).

  5. Dan says:

    ISO 8601 says a “calendar week” is a “time-interval of seven days, starting on a Monday”, and a “calendar week number” is “its ordinal position within the year, applying the rule that the first calendar week of a year is the one that includes the first Thursday of that year”.

    Since AFAIK there’s no definition of week numbers other than the European/ISO one, it makes a certain amount of sense to stick with those rules even when displaying a calendar with the week starting on Sunday. But that could also just be confusing. :-/

  6. pdw says:

    According to ISO, the first week is the week containing the first Thursday. So Planner’s Gantt chart is correct ISO-wise: the first week of 2006 starts on January 2nd.

  7. Vidar says:

    Week 1, as defined by ISO 8601, is the week that has the first thursday of that year.

  8. David Weinehall says:

    Wikipedia says this about iso-8601 (which is the only *sane* date standard):

    “Week 01 is the week with the year’s first Thursday in it. If 1 January is on a Monday, Tuesday, Wednesday or Thursday, it is in week 01. If 1 January is on a Friday, Saturday or Sunday, it is in week 52 or 53 of the previous year. Weeks 01, 52 and 53 can thus include days from more than one year and, in most years, do so.”

  9. I bet you'll never guess... says:

    My god…I stumbled upon this very interesting blog by chance, and the most shocking thing? Robert, I actually know who you are, as in we have met, or indeed did meet for most days of the year, unavoidably, for several years, well a few years ago anyway. What an entirely random set of circumstances. Anyway, I am very sorry for adding a slightly rambling quality to this very intelligent discussion but I couldn’t really let the occasion go by without saying Hello 🙂 If you can guess who I am (or indeed even ever read this comment) or even want to guess then get in touch.

    Nice blog by the way, very interesting at 1045 on a Monday morning!

    Moi
    xx

  10. Peter Grayley says:

    Hi,

    I was looking for how to make Outlook (XP) comply with the ISO 8601 standard (as we’re working with a Dutch customer who uses it). If anyone needs to know:

    Tools->Options->Calendar Options,
    then change the “First week of year” field to
    “First 4-day week”.

    Enjoy.

    Peter

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.