This article is rated C-class on Wikipedia's content assessment scale. It is of interest to the following WikiProjects: | |||||||||||
|
Nearly a B.
Want to help write or improve articles about Time? Join WikiProject Time or visit the Time Portal for a list of articles that need improving.
—Yamara ✉ 18:18, 14 February 2008 (UTC)
Ok, I understand now "What if most years had a leap week?". What matters for the maximum change of corresponding equinoxes between two years is the largest deviation of a year from the average year.--Patrick 21:38, 30 May 2006 (UTC)
I would situate the following sentence at the beginning: The first week of a year is the week that contains the first Thursday of the year. It is also (equivalently) the week containing the 4th day of January.
Everybody looks for that information and has to read half a page to get to it.
Currently prior we talk about iso. Well, that´s scientific correct, but I think people look for a trivial explanation first and than for the scientific one. My opinion of course br hans.stangl@gmx.at --194.113.154.132 (talk) 08:15, 26 February 2014 (UTC)
I have seen ISO 8601:2000 but not ISO 8601:2004. ISO 8601:2000 does not use the term "leap week"; I don't know whether ISO 8601:2004 does.
Unless the term is introduced in ISO 8601:2004, it seems to me unwise to introduce it elsewhere; "week 53" suffices. It leads to using "leap year" for 53-week years, which clashes with conventional use. It might be thought to mean a week containing February 29th.
Re section "Disadvantages" : The ISO Week Calendar could fully replace the Gregorian, because it is possible to calculate Day 1 of a given year directly - but the expression will be more complicated.
Re section "Advantages" : Although the date of Easter Sunday would be no easier to calculate, the number of possible dates would be less, since all are Day 7. Only a few Week Numbers would be possible. 82.163.24.100 13:45, 30 January 2007 (UTC)
Only six Week Numbers, 12-17 would be possible, 17 being rare. 82.163.24.100 22:19, 3 February 2007 (UTC)
ISO 8601:2004 does not use "leap week". It does use "leap year", but in the common sense of a year with 366 days; accordingly, "leap year" should not be used to refer to an ISO year of 53 weeks.
Library routines purporting to convert other forms of date into ISO week dates should be viewed with caution; errors are known to occur, for example with 2007-12-31.
There is only ONE definition of Week 01; it is in ISO 8601:2004 2.2.10, and uses 'first Thursday' (and see 3.2.2 note 3). The others are mere equivalent consequential descriptions.
82.163.24.100 10:52, 26 May 2007 (UTC)
Done
I stopped reading this article when I saw "leap week" followed by the comment that it isn't in the standard. It needs to be edited out or the article delelete completely - Wikipedia is not a place for original research or soapboxing.114.198.81.18 (talk) 09:41, 11 September 2016 (UTC)
* [[Template:ISOWEEKDATE]] - ((evd|ISOWEEKDATE|2010|01|03)) The opposite function of ((tl|ISOWEEKDATE2YMD)) :* [[Template:ISOYEAR]] - ((evd|ISOYEAR|2010|01|03)) :* [[Template:ISOWEEK]] - ((evd|ISOWEEK|2010|01|03)) :* [[Template:ISOWEEKDAY]] - ((evd|ISOWEEKDAY|2010|01|03)) * [[Template:ISOWEEKDATE2YMD]] - ((evd|ISOWEEKDATE2YMD|2009|53|7)) The opposite function of ((tl|ISOWEEKDATE)) :* [[Template:ISOWEEKDATE2Y]] - ((evd|ISOWEEKDATE2Y|2009|53|7)) :* [[Template:ISOWEEKDATE2M]] - ((evd|ISOWEEKDATE2M|2009|53|7)) :* [[Template:ISOWEEKDATE2D]] - ((evd|ISOWEEKDATE2D|2009|53|7))
Use the ((#time
)) parser function instead. JIMp talk·cont 07:26, 1 June 2012 (UTC)
These are to be deleted. JIMp talk·cont 23:35, 4 June 2012 (UTC)
I don't get this part: "It cannot replace the Gregorian calendar, because it relies on it to define the new year day (Week 1 Day 1)."
Is what you want to say that if it coexists with the Gregorian Calendar then it has to be decided which one of them that tells when to celebrate new year's eve since the days for a new year differs?
I can see no logical reason to why new year couldn't be defined as Week 1 Day 1. I mean it's pretty much how it is now with the leap days, we don't celebrate the new year on different times on the day even if it supposedly moves approx 6 hours each year.
--Crouz 20:50, 4 November 2007 (UTC)
Done
Poor wording (in the article, not yours). It's intended to co-exist with the Gregorian calendar rather than replace it. To decide whether the year has 53 weeks you refer to the Gregorian calendar. If we wanted to replace the Gregorian calendar, a simpler algorithm would be preferable. JIMp talk·cont 07:34, 1 June 2012 (UTC)
Having seen the rubbishy code of two major software suppliers, and noting that the recent products of one have code which is not only bloated but wrong, I think that adding something on Algorithms would be justified.
To convert a Gregorian date into an ISO 8601 Week Numbering date Y W D, all that is necessary is to :-
Determine its Day of Week, D Use that to move to the nearest Thursday (-3..+3 days) Note the year of that date, Y Obtain January 1 of that year Get the Ordinal Date of that Thursday, DDD of YYYY-DDD Then W is 1 + (DDD-1) div 7
or very similar.
Observe that there is no need to consider any special cases.
Here are well-tested Delphi routines for the comversions of a TDateTime (Local daycount from 1899-12-30 00:00:00 = 0.0) to and from Y W D form :-
procedure ISODTtoYWD(const DT : TDateTime ; out YN, WN, DN : word) ; var X : word ; NThu, Jan1 : TDateTime ; begin // The canonical version. DN := 1 + (DayOfWeek(DT)+5) mod 7 { DT : Mon=1 to Sun=7 } ; NThu := Trunc(DT) + 4 - DN { NThu is the Nearest Thursday } ; DecodeDate(NThu, YN, X, X) { get Year Number of NThu } ; Jan1 := EncodeDate(YN, 1, 1) { January 1 of YN } ; WN := 1 + Trunc(NThu-Jan1) div 7 { Count of Thursdays } ; end {ISODTtoYWD} ;
function ISOYWDtoDT(const YN, WN, DN : word) : TDateTime ; var DT : TDateTime ; DW : integer ; begin // The canonical version. DT := EncodeDate(YN, 1, 4) { YN Jan 4, which is in YN Week 1 } ; DW := 1 + (DayOfWeek(DT)+5) mod 7 { DT : Mon=1 to Sun=7 } ; DT := DT - DW { DT to day before Week 1 } ; Result := DT + (WN-1)*7 + DN { increment for Weeks and Days } ; end {ISOYWDtoDT} ;
A slight speed-up is possible, at the expense of clarity.
Javascript versions are in http://www.merlyn.demon.co.uk/weekcalc.htm .
82.163.24.100 (talk) 21:19, 19 March 2008 (UTC)
Here is a C# .NET implementation. I've tested it against all of the test cases, and it passes.
public class ISO_Week { public int year; public int week; public int dayOfWeek;
public ISO_Week(DateTime dt) { if (CultureInfo.CurrentCulture.DateTimeFormat.FirstDayOfWeek != DayOfWeek.Monday) throw new NotImplementedException("This only works for cultures with Monday as the first day of the week."); —Preceding unsigned comment added by 194.28.249.49 (talk) 06:29, 20 April 2011 (UTC) dayOfWeek = 1 + ((int)dt.DayOfWeek + 1+5) % 7; // Mon=1 to Sun=7 DateTime NearestThu = dt.AddDays(4 - dayOfWeek); year = NearestThu.Year; DateTime Jan1 = new DateTime(year, 1, 1); TimeSpan ts = NearestThu.Subtract(Jan1); week = 1 + ts.Days / 7; // Count of Thursdays } }
--19:51, 24 February 2010 71.141.227.160
Using calculations based on a linear scale like the Rata Die number can be more useful in programming. If we want to calculate the Rata Die of a ISO week date we can use the relation to the Gregorian calendar and write the following Python code:
def isocal_date2rdn2(y,w,d): y -= 1 ew = (y*365 + y//4 - y//100 + y//400 + 3) // 7 return (ew + w - 1) * 7 + d
Here y, w, d are year, week and day-of-week of the ISO week calendar date. It is important to understand that Python's '//' operator implements floor division, which is important if one of the quantities involved leaves the nominal range and becomes negative.
The algorithm is rather simple: It uses the Gregorian calendar to get the number of days elapsed since the begin of the Christian Era (0001-01-01) and converts this number in a rounding manner to the number of elapsed weeks ('ew') for the begin of the year in the ISO week calendar. Then it adds the number of elapsed weeks in the year and uses the total number of elapsed weeks and the day-of-week to get the Rata Die of the ISO week date.
The reverse operation is a bit more tricky and is based on extensive exploration of the tabulated elapsed weeks for every year of a 400-year cycle. It can be shown that for every century it's possible to plot a cohort of straight lines through the tabulated data in such manner that every line of the cohort is always above the tabulated data and that the difference between the line and the data is always less than 1. Then the conversion from elapsed weeks since begin of a century to the number of elapsed years can be done with a linear transformation of the form
Since there is a cohort of possible slopes, one can find integer coefficients a, b and k where
'//' again denoting integer floor division. It can further be shown that there is a cohort of slopes common to all 4 centuries. This results in common values for a and k, but the additive constant b has to be chosen differently for every century.
Another observation is that the first, third and last century of a cycle have 5218 weeks, and the the second century has only 5217 weeks. If we apply the proper correction for weeks >= 10435, we can get the elapsed centuries and the weeks in the century through division by 5218.
Plumbing this all together, we yield the following Python code:
# selected values: a=28 k=1461 b=[15,23,3,11] def isocal_rdn2date1(rdn): w,d = divmod(rdn-1, 7) n,w = divmod(w, 20871) # weeks in 400 years c,w = divmod(w + (w >= 10435), 5218) # get century and weeks in century y,w = divmod(w * 28 + (15,23,3,11)[c], 1461) # get years in century and scaled weeks in year return (n*400 + c*100 + y + 1, (w // 28) + 1, d + 1) # get y,w,d in ISO week calendar
There are of course many coefficient sets for a, k, b0..b3 that yield the desired result; a=157 k=8192 b=[85,131,17,62] has the advantage that the division and modulo operation can be carried out by shift and mask operations in languages like C.
j.perlinger (perlinger-at-ntp-dot-org) 217.81.188.179 (talk) 00:59, 9 December 2011 (UTC)
The definition of the first week in the iso calendar mentions:
Mutually equivalent definitions for week 01 are:
However this cannot be true, for in 2009 they fall on different weeks:
January 2009 S M Tu W Th F S 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
—Preceding unsigned comment added by 192.65.45.20 (talk • contribs)
Done
I would like to see a little bit about the calendar's history. When was it first used? And by whom? Who or what agency invented it? For example, the link to years-with-leap-weeks says that the "first" one is 2009. Do they mean the "next" one? Or is the calendar so recent that we haven't had one yet? —Preceding unsigned comment added by MiguelMunoz (talk • contribs) 01:59, 11 July 2008 (UTC)
I would also like to know *specifically* who submitted the standard and also, for religious reasons, specifically why they chose Monday as the first day of the week when the first day of the week has been Sunday for centuries. Is the Catholic Church STILL trying to move Sun's Day to the 7th day of the week? Interesting for the scholastic theologians among us. WebTigers (talk) 17:08, 5 July 2011 (UTC)
The article used Gregorian Year correctly, and used ISO year to mean the yyyy of yyyy-Www-d. But the yyyy of yyyy-mm-dd is also fully defined in ISO 8601, and has priority. Alas, ISO offers no convenient term for the week-numbering year. Therefore, I have changed "ISO year" to "ISO week-numbering year" except where the "week" context was strong enough already.
ISO 8601 says nothing about "leap week". I have changed the article accordingly. While the term is useful in classifying calendars in accordance with which unit they occasionally insert, there has been in the Article a source of possible confusion in using "leap year" to refer to a 53-week year, because its use to refer to a Jan..Dec containing a Feb 29 is so thouroghly established. That may need further attention.
For details, see the History page.
82.163.24.100 (talk) 12:49, 22 September 2008 (UTC)
Done
The ISO standard does not connect weeks to months in any way. The recent addition working this out in great detail is not based on the standard and therefore does not belong in this article. Additionally, whenever for practical purposes (mostly financial) weeks are assigned to months, this is rarely done in the way described. The usual way is to have fixed 4-4-5 or 5-4-4 patterns. The section is not sourced and constitutes clear WP:OR. −Woodstone (talk) 03:37, 27 March 2010 (UTC)
the first calendar week of a year is that one which includes the first Thursday of that year
— ISO 8601:2004, section 2.2.10
If, however, the rule for first week of the year was applied to Gregorian months the pattern would be irregular. The only 4 months (or 5 in a long year) that would have 5 weeks were those with at least 29 days starting on Thursday, those with 30 or 31 days starting on Wednesday, and those with 31 days starting on Tuesday.
Weeks per month depending on the weekday of 1 January; in leap years adjacent months may switch their week count (“4* 5*”) 1 Jan Mon Tue Wed Thu Fri Sat Sun Jan 4 5 5 5 4 4 4 Feb 4* 4 4 4 4 4 4 Mar 5* 4 4 4 4* 5 5 Apr 4 4 4* 5 5* 4 4 May 5 5 5* 4 4 4 4* Jun 4 4 4 4 4* 5 5* Jul 4 4* 5 5 5* 4 4 Aug 5 5* 4 4 4 4* 5 Sep 4 4 4 4* 5 5* 4 Oct 4* 5 5 5* 4 4 4 Nov 5* 4 4 4 4 4* 5 Dec 4 4 4* 5 5 5* 4 Year 52 52 52* 53 52 52 52
I reverted (again) because you still have not given a reference to show that it is used in a significant real world environment. −Woodstone (talk) 14:30, 9 August 2010 (UTC)
|
|
|
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|
I’ve moved the section Calendar cycle to section Weeks per year, after I had added some simple observations on the pattern there. These contradict! Could someone please check the list of years with 53 weeks on the one hand and the cycle calculations with doomsday and dominical letters on the other hand? — Christoph Päper 10:42, 23 March 2011 (UTC)
Why does the article not mention that dates in week-date format are basically incomprehensible to a human viewers? I definitely expected this to be listed in the disadvantages section... 203.206.239.111 (talk) 00:54, 12 May 2011 (UTC)
Article: The ISO 8601 definition for week 01 is the week with the year's first Thursday in it.
There's no mention of why it's Thursday. Was it an arbitrary choice or is there some rationale? As this scheme is about working weeks, why wasn't it the naively obvious candidate, Monday? 92.0.230.198 (talk) 12:53, 17 January 2015 (UTC)
Verdy p (talk · contribs) put this into an inline comment in an edit that I’ve reverted:
FALSE assertion: “There is no simple algorithm to determine whether a year has 53 weeks without tabular lookup from its ordinal number alone.”
NO table lookup is necessary: to determine the weekday for January 4 in that year , and to see if that year is leap (has a February 29), only requires modular arithmetic (without any test) in both parts, based only the year ordinal number.
So what’s a simple algorithm to determine from the ordinal year number a) whether it has a 53rd week or at least b) what’s the DOW of 4 January? — Christoph Päper 19:53, 27 April 2016 (UTC)
((JULIANDAY|2016))
returns 2457389 (computed value for 1 January 2016, at 12:00:00 UTC), and modulo 7 you have the answer: 4 (Friday, as 0 means Monday with this simple formula).((JULIANDAY|2016|1|4))
returns 2457392 (computed value for 4 January 2016, at 12:00:00 UTC), and modulo 7 you have the answer: 0 (Monday).The comment(s) below were originally left at Talk:ISO week date/Comments, and are posted here for posterity. Following several discussions in past years, these subpages are now deprecated. The comments may be irrelevant or outdated; if so, please feel free to remove this section.
Good technical description! It would be really nice to have, in addition, a table or a clickable calendar, which at minimum lists the first day of week 1 for a whole bunch of years, or (even better) enables one to enter a year/month/day and get back the week number for that date. I don't know if this is too difficult. But I spent quite some time reading this article before I found what I wanted--that week 1 in 2010 starts on Jan 4. Hambleton (talk) 19:18, 13 April 2009 (UTC) |
Last edited at 19:18, 13 April 2009 (UTC). Substituted at 20:02, 1 May 2016 (UTC)
There’s a section entitled “Dates with fixed week number”. I’m considering to change it in a way that it says something about possible week numbers for all dates not just the ones with 100% or 97% likeliness, but I’m not sure yet whether and how this should be done.
From January 4 through February 29, all dates fall in one of two weeks of the same year. The probabilities repeat every seven days. If multiplied by 400 (or 97 for Feb29), one gets the absolute occurences per Gregorian leap cycle.
Weeks | Jan04 Jan11 Jan18 Jan25 Feb01 Feb08 Feb15 Feb22 Feb29 | Jan05 Jan12 Jan19 Jan26 Feb02 Feb09 Feb16 Feb23 | Jan06 Jan13 Jan20 Jan27 Feb03 Feb10 Feb17 Feb24 | Jan07 Jan14 Jan21 Jan28 Feb04 Feb11 Feb18 Feb25 | Jan08 Jan15 Jan22 Jan29 Feb05 Feb12 Feb19 Feb26 | Jan09 Jan16 Jan23 Jan30 Feb06 Feb13 Feb20 Feb27 | Jan10 Jan17 Jan24 Jan31 Feb07 Feb14 Feb21 Feb28 |
---|---|---|---|---|---|---|---|
W0n | 100% | 85¾% | 71½% | 57% | 43% | 28½% | 14½% |
W0n+1 | 0% | 14¼% | 28½ % | 43% | 57% | 71½% | 85½% |
From March 1 till December 28, the ratios change by a tad over 3% due to leap years beginning on a Thursday (DC) which have the Thursday of W09 on February 29, i.e. the only years where 5 weeks belonged to February if one applied the Thursday rule.
Weeks | Mar01 … Dec27 | Mar02 … Dec28 | Mar03 … Dec22 | Mar04 … Dec23 | Mar05 … Dec24 | Mar06 … Dec25 | Mar07 … Dec26 |
---|---|---|---|---|---|---|---|
Wn | 96¾% | 82¼% | 68% | 53¾% | 39¼% | 25¼% | 10¾% |
Wn+1 | 3¼% | 17¾% | 32% | 46¼% | 60¾% | 74¾% | 89¼% |
Around New Year, things get a bit more complicated, because the dates December 29 through January 2 can fall in 3 different weeks: W53 usually spans Dec28–Jan03, but in DC years Dec27–Jan02. That means it contains 7 out of 8 possible dates, whereas weeks W01–W08 have a range of 13 possible dates and the rest even 14 dates.
Week | Dec27 | Dec28 | Dec29 | Dec30 | Dec31 | Jan01 | Jan02 | Jan03 | Jan04 |
---|---|---|---|---|---|---|---|---|---|
W52 | 96¾% | 82¼% | 68% | 53¾% | 39¼% | 25¼% | 10¾% | 0% | 0% |
W53 | 3¼% | 17¾% | 17¾% | 17¾% | 17¾% | 17¾% | 17¾% | 14½% | 0% |
W01 | 0% | 0% | 14¼% | 28½% | 43% | 57% | 71½% | 85½% | 100% |
Last | 85½% | 100% | 85¾% | 71½% | 57% | 43% | 28½% | 14½% | 0% |
W52/53 | 100% | 100% | 85¾% | 71½% | 57% | 43% | 28½% | 14½% | 0% |
Ordinal days, DDD, are similar to Jan/Feb dates, because the 366th (leap) day is appended at the end of the year. That means, one could provide a simple formula using modulo 7 to get the week number from the three-digit day number.
Any suggestions or concerns, diagrams, tables or references (besides RH van Gent’s site)? — Christoph Päper 20:15, 4 July 2016 (UTC)
This article is very informative, rich in facts, but unfortunately it has very few citations - so it is difficult to verify against sources. I appreciate that many references might point to ISO materials – however there are entire sections, tables, algorithms and formulae that really could do with some pointers to sources, so that we can be sure there is no original research in here. For now I have tagged the whole page as `more citations needed` to get the ball rolling. See the parent page ISO 8601 for examples of more comprehensive referencing and see WP:CITE for help. Artemgy (talk) 14:11, 28 March 2020 (UTC)
We should change this title to "Differences" since every Person has a different understanding if this is a Disadvantage. --MajorValerian (talk) 13:32, 7 May 2020 (UTC)
From the list of properties of the first week of a year:
This only works if 2 January is a working day. If 1 January is on a Thursday and 1 and 2 January are off then the first working day will be on Monday, 5 January, which is in Week 2. In some regions 2 January is a holiday, where I live it is Berchtoldstag. --Adi86 (talk) 14:14, 20 February 2021 (UTC)
"A precise date is specified by the ISO week-numbering year in the format YYYY, a week number in the format ww prefixed by the letter 'W', and the weekday number, a digit d from 1 through 7, beginning with Monday and ending with Sunday." WRONG. Technically, Sunday is 0, not 7. Because 1 week is already 7 days and Base 7 doesn't have the number 7. Also, in "The last week of the ISO week-numbering year, i.e. W52 or W53, is the week before W01 of the next year.", there is no W53 or WK53. The first week of the year is W00 or WK00. Please don't delete this text. Thank you for understanding. 2404:3C00:502F:4C80:94CC:986C:1979:3C38 (talk) 06:18, 3 March 2021 (UTC)
It would be better to add 1 or 2 8-day weeks every year, so every year starts with Sunday. The weeks should be numbered from 00 to 51 and the days should be numbered from 0 to 6 or 7. That way, it would be easier to skip count.
SKIP COUNTING BY 10 DAYS USING WEEK DATE FORMAT
0000-01-3
0000-02-6
0000-04-2
0000-05-5
0000-07-1
0000-08-4
0000-10-0
0000-11-3
0000-12-6
0000-14-2
And so on... 2404:3C00:502F:4C80:E1F6:7353:D1D1:F484 (talk) 03:39, 24 July 2021 (UTC)
I wonder what the reasoning was behind the change of contemporary examples to 1970s/80s dates instead of the more recent and arguably more relatable dates in the 2000s: https://en.wikipedia.org/w/index.php?title=ISO_week_date&type=revision&diff=1013225877&oldid=1012594781
Also the example about a bug with Twitter in 1986 does not make any sense at all now: "A programming bug confusing these two year numbers is probably the cause of some Android users of Twitter being unable to log in around midnight of 29 December 1986 UTC."
I propose reverting those changes.
Fdemmer (talk) 08:21, 23 March 2021 (UTC)