54 Weeks in 2000 : Another Y2K Problem!

Version 2.3, 2003-01-09

by

Stan Sieler, Barry Lake, and Michael Hensley

Allegro Consultants, Inc. (www.allegro.com)



Many software applications define a "week-of-year", also known as "fiscal week" or "calendar week", which is used for a variety of purposes. Usually, such weeks are defined as starting on Sunday and ending on Saturday (This differs from the ISO standard, of course ... but that doesn't change the fact that many programs (and human calendars) treat Sunday as the first day of the week.)

This paper deals with a Y2K problem that surfaces when a Sunday-starting week is used.

A normal year has 53 weeks, where 51 or 52 are "complete" weeks, and 1 or 2 are "incomplete" (or "partial"), since they start or finish in the prior or following year.

For example, 1999 has 53 weeks. The first week has two days in 1999: Friday, January 1 and Saturday, January 2. The last week has six days in 1999, and ends on Friday, December 31.

If there were only 364 days in a year, and if the year started on a Sunday, then every year would have exactly 52 weeks. However, we aren't that lucky, and no year ever has fewer than 53 weeks.

As fate would have it, the year 2000 has 54 weeks! The first week has one day: Saturday, January 1, and the 54th week has one day: Sunday, December 31. (see footnote #2 for why we called this a Y2K problem).

It turns out that a 54-week year happens once every 28 years, so the last time was 1972 ... well before the birth of many software packages now in common use.

A 54-week year wouldn't be a problem if programmers had been aware of it, but we've seen several programs which actually assume that the number of weeks in a year is always 53. This can cause two kinds of problems:

This isn't just a theoretical problem, of course. We encountered it in source code we maintain for one of our clients. The team which found and characterized the problem consisted of Barry Lake and Michael Hensley

----------

Company background: Allegro Consultants, Inc. has been working on Y2K issues for many years. We wrote the internal white paper which Hewlett-Packard used for the start of its Y2K efforts in HP-UX and MPE/iX. We also wrote HourGlass 2000 for the HP 3000 and HourGlass 2000 for the HP 9000, two date/time simulator tools.


Footnotes:
  1. ISO Standard 8601 describes standards for dates, including the numbering of the weeks of a year.
    In the ISO standard, a week begins on Monday and ends on Sunday, and the first week of a year must include a Thursday from that year. If the software we encountered had followed *ISO* standard, the "54 weeks" problem would not have occurred. The ISO standard is available for purchase at:
    http://www.iso.ch/iso/en/CatalogueDetailPage.CatalogueDetail?CSNUMBER=26780.
    A good description is at: http://www.cl.cam.ac.uk/~mgk25/iso-time.html.

  2. We call this a Y2K problem because, for practical purposes, it first occurs in the year 2000. The last time a year had 54 weeks was 1972, before most software programs were written. Further, this is considered a Y2K problem because it was discovered during a Y2K remediation source code review.
Thanks to Lars Mouritsen for ISO 8601 links!


Additional information on the ISO 8601 Standard:
Thanks to Ian Galpin (g1smd at amsat dot org) for the additional ISO 8601 links!

Updated: 2003-01-08