Week of the Year

折月煮酒 提交于 2019-12-24 06:26:32

问题


As per ISO 8601, the first week is the week having at least 4 days and week start with Monday. For countries where the week starts with another day, like Sunday, how is the first week defined ?


回答1:


Weeks can be defined in all sorts of ways.

The ISO 8601 standard way (starts on Monday, week # 1 has first Thursday of year) is sensible and practical, and increasingly common. In Java and its java.time framework (see Tutorial), the standard defined behavior is encapsulated in the IsoFields class. See my Answer to another Question for examples.

The non-standard approaches vary widely. Be very clear in determining such definitions with the stakeholders in your project. Document the definitions in your code base as well.

Often a company uses their own defined fiscal year for other business purposes, while some companies use the fiscal year only for bookkeeping and another calendar system for operations. Often the fiscal year is defined by its last day being a certain day-of-week such as the Friday closest to 31 December. So a year may have 52 or 53 weeks.

Sometimes week number 1 is the week containing January 1. Some people include the prior days of that week (December 31, December 30, etc.) in that new year’s week while some people cut the week into two parts (last year’s part and new year’s part).

Some define week # 1 as the earliest week that contains the first day of the week. Of course that first day of the week is defined by cultural norms such as Sunday in the United States.

Some people define week number 1 as the first complete week of the year, having no days from the previous years. So January 1, January 2, and so on may be counted in the last year.

Some industries and some companies define their own weeks of the year. Some are predictable with a pattern that can deterministically be projected out into the future, while some are arbitrary and defined by humans every year or two or three.

Until the 1990s, the Eastman Kodak Company for decades used and promoted a very different calendar system, the International Fixed Calendar. This system provides for a year of 13 months of 28 days each (exactly 4 weeks), with every date fixed always on the same weekday. So every year has week # 1 starting on Sunday January 1.

The French Republican Calendar is another different calendar in use for over a decade, with a ten-day week.

Keep your mind open, to make sense of date-time matters such as this. Understand that while a day is defined by nature (spinning of the earth) and a year is defined by nature (Earth’s orbit around the Sun), weeks and months and such are inventions of humans. The definition is subject to human creativity and to human folly (ex: Daylight Saving Time nonsense).




回答2:


Being a standard, it's standardized. Same everywhere.

See Wikipedia page.



来源:https://stackoverflow.com/questions/36754365/week-of-the-year

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!