I need to calculate the number of the current week in a year in ISO 8601 form. I thought it is easy but so far i have tried 5 times and failed 5 times.
Can you think of any built in functions in REXX, JCL, ISPF, etc... that I could use or anyone has managed to put together a code that is working fine?
Normally i do not ask anyone to write a code to me as i can go with redbooks and guidance but here i give up
Probably i've become too obsessed with this weeknumber thing and can't see where i get it wrong.
thanks,
david
Please see the below description of what ISO 8601 calendar format means:
"The ISO 8601 Calendar
This week numbering scheme was introduced earlier by the ISO with the standard ISO 2015:1976 (Numbering of Weeks) and was repealed on 1 June 1988 with the imminent introduction of ISO 8601. The calendar defined in the ISO standards 2015 and 8601 is commonly referred to as the “ISO calendarâ€.
The ISO calendar corresponds with the Gregorian calendar (sect. 3.2.1 on pp. 7-8) and uses the same year number but as its length is defined to be an integral number of weeks, its beginning can deviate up to a few days from 1 January and its end likewise can deviate up to a few days from 31 December. On average, however, it remains in step with the Gregorian calendar.
The week in the ISO calendar is defined (sect. 2.2.8 on p. 5) as a:
time interval of seven calendar days starting with a Monday [...] identified by its ordinal number within its calendar year.
The numbering of the ISO calendar weeks is defined (sect. 2.2.10 on p. 5) as:
[...] the first calendar week of a year is that one which includes the first Thursday of that year and [...] the last calendar week of a calendar year is the week immediately preceding the first calendar week of the next calendar year.
Another way of stating the above rule is that the first week of the ISO calendar year is the earliest week that contains at least four days of the month of January. Likewise, the last week of the ISO calendar year is the last week that contains at least four days of the month of December."