std-unix@ut-sally.UUCP (01/28/87)
From: seismo!gatech!hpcnof!hpfcla!hpfclj!hpfcdg!rgt Date: Mon, 12 Jan 87 15:21:04 est > 2. If the year begins on Saturday and ends on Monday, it will have 54 > weeks. Obviously they cannot be numbered 00 to 52! Sorry folks, but this is not a bug. This was transcribed from the X3J11 documentation titled "Internationalizing ANSI C" and numbered "X3J11/86-125R". Section 3.2 describes the strftime funtion and describes the %U and %W directives. Both are described as being week numbers beginning with either Sunday or Monday and both list a range of 00 to 52. (The %W directive was changed to a %V directive because it conflicts with an existing X/OPEN directive for the nl_cxtime function, which is almost identical in operation to strftime.) I believe that the intended week number computation is as described in a paper titled "An Overview of Internationalization" by Greger K. Leijonjufvud of Sperry Corporation and Gary L. Lindgren of AT&T (no date or number). In section 3.4.2.4 titled "The Week" it states [with my corrections and clarifications (rgt)]: The 7-day week is now predominant. Each day has its name and is also numbered. the number depends on which day is counted as the starting day of the week: either Sunday or Monday. Weeks are also numbered. Which week tath is counted as the first depends on the weekday of January 1st (i.e., if there are 4 or more January days in the week of Jan 1st, then that is week 1, [number 00 (rgt)] otherwise it is week [51 or (rgt)] 52 of the preceding year. The calculation also depends on whether Sunday is the first or the last day of the week.) The maximum number of weeks in a year would occur in a leap year with January 1st on the Wednesday of the Sunday-first week. Looking at a perpetual calendar, 1964 or 1992 are useful examples. I derive the following table: 1963 week ?? = Dec 22 to Dec 28 1964 week 00 = Dec 29 to Jan 04 ... 1964 week 52 = Dec 27 to Jan 02 1965 week 00 = Jan 03 to Jan 09 Conversely, the minimum number of weeks in a year would be occur in a non-leap year when January 1st was on a Thursday of the Sunday-first week. 1986 week ?? = Dec 28 to Jan 03 1987 week 00 = Jan 04 to Jan 10 ... 1987 week 51 = Dec 27 to Jan 02 1988 week 00 = Jan 03 to Jan 09 Conclusion: A week-aligned year may will have at least 52 weeks and at most 53 weeks. The first day (00) of the first week (00) of the week-aligned year may be as early as Dec 29 and as late as Jan 04. All of the arguements can also be applied to a Monday first week with only minor changes. Volume-Number: Volume 9, Number 33