如果有人说某事发生在某个月的第一周或最后一周,您会如何定义该跨度?
<小时/>背景
我正在开发一个需要以直观的方式处理此类事情的库,但我的直觉并不支持任何一种情况。
我可以让它选择不同的行为,但仍然需要一个好的默认值。
<小时/>作为具体示例,我将随机选择一个月份:2008 年 7 月
s m t w r 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
(注意:我假设一周从星期日开始,但也可以在星期一提出问题)
该月的第一周是多长时间?
- 6 月 29 日 - 7 月 5 日-- 包含第一周的一周
- 7 月 6 日 - 12 日-- 该月的第一周
第二周就是第一周之后的 7 天吧?
该月的最后一周是多长时间?
- 7 月 27 日 - 8 月 2 日-- 同上,但最后一天
- 7 月 20 日 - 26 日-- 同上,但上周
欢迎非维基评论
最佳答案
There is no answer because it varies even inside a country.
但是,this source似乎认为 ISO 标准将其定义为包含星期四的第一周。然而,上述消息来源称 ISO 标准并未列出“每月第一周”的规范
<小时/>超过 300 个字符 - 抱歉!
ISO 8601 标准将一年的第一周定义为:
calendar week number
ordinal number which identifies a calendar week within its calendar year according to the rule that the first calendar week of a year is that one which includes the first Thursday of that year and that the last calendar week of a calendar year is the week immediately preceding the first calendar week of the next calendar year
ISO 8601 中没有关于每月第一周的内容,因为如前所述,定义因国家/地区(甚至公司等)而异。哦,标准规定每周从星期一开始。
关于date - 一个月的第一周/最后一周是星期几?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/604031/