Week numbers and BYWEEKNO and weeks start with Monday, Sunday, Saturday (WKST)
How the week number is entered and sent in an ics file is important in two areas of this events plugin.
- For communication with other calendar systems, one must stick to the ical RFC5545 (ie : ISO 8601) definition so that recurring dates will be accurately reflected.
- For listing of events (agenda or calendar style) however there may be expectations of other week numberings (For example many timeshare resorts use very different week numbering systems, depending on when “their” weeks start – eg: Friday, Saturday, Sunday.) It is simply not possible to cope with all of these, at this stage . The RFC5545 spec (see below) implies that one can combine BYWEEKNO and WKST to give some flexibility. The amr events plugin will pick up the week start defined in your wordpress website.
What does the plugin do wrt week numbers ?
When entering a week number, the ISO8601 in combination with the weekstart (WKST ) will be expected. To aid data entry, it will be checked against the start date (which must be in the week number) and the error message will tell you the wek number of the start date.
At launch, the listing plugin is limited to using the PHP functions for calculating the week number.
Week number definitions:
Wikipedia has some discussion on various usages or week number definitions under the 7 day week, week numbering heading. There are many – it is not just a case of
- which day the week starts on (Monday, Sunday, Saturday, Wednesday (Hungary?)), but also
- what defines where one begins in the year with partial weeks or full weeks
- Week containing Jan 1 (Eastern European, India, Arabic countries, Canada, China etc..)
- Week containing Jan 4 (European countries)
- Week containing Jan 7 & Monday (Eastonia and Pakistan)
A list of these is available at pjh2.de and more information from JR Stockton
Technical Definitions of BYWEEKNO
From the RFC5545 Specification:
The BYWEEKNO rule part specifies a COMMA-separated list of ordinals specifying weeks of the year. Valid values are 1 to 53 or -53 to -1. This corresponds to weeks according to week numbering as defined in [ISO.8601.2004]. A week is defined as a seven day period, starting on the day of the week defined to be the week start (see WKST). Week number one of the calendar year is the first week that contains at least four (4) days in that calendar year. This rule part MUST NOT be used when the FREQ rule part is set to anything other than YEARLY. For example, 3 represents the third week of the year.
Note: Assuming a Monday week start, week 53 can only occur when Thursday is January 1 or if it is a leap year and Wednesday is January 1.
This note from aspose.com advises: Use BYWEEKNO only when conformance with ISO 8601 is required. Week numbers as defined by ISO 8601 are very different from week numbers in “common” sense. According to ISO 8601, week number one of the calendar year is the first week of a calendar year that contains at least four days. This rule makes the algorithm specific to applications requiring conformance to ISO 8601 and make it almost inapplicable to other “normal” uses.
ISO 8601 is supported by some European banking and financial applications. It is also used in Television for booking commercials. An ISO week calculator can be found at http://www.personal.ecu.edu/mccartyr/isowdcal.html
The BYWEEKNO rule specifies a comma-delimited list of numbers identifying weeks of the year. Valid values are 1 to 53 and 1 to 53. This corresponds to weeks according to week numbering as defined in ISO 8601. BYWEEKNO is only valid for YEARLY rules.
To illustrate, the following are two very different recurrence patterns:
- Friday of 1st ISO 8601 week of the year: FREQ=YEARLY;BYWEEKNO=1;BYDAY=FR
- 1st Friday of the year : FREQ=YEARLY;BYDAY=1FR
In 1999, for example, 1st Friday of the year is 1999/01/01, while Friday of the 1st ISO 8601 week is 1999/01/08.
So what is the current week number?
These sites help if your week starts on a Monday: