C# 中的 DayOfWeek(枚举)(概念)
DayOfWeek (enum) in C# (concept)
一段时间以来,我一直致力于 class 处理重复性任务(例如提醒或日历中的计划事项)。我注意到在 C# 中,枚举的 int 值是:
周日 - 0
星期一 - 1
...
周六 - 6
我在 OS X 的日历中也看到了同样的情况 - 让面板选择要安排的日期,它从第 1 位的星期日开始,然后是星期一,依此类推。
为什么?为什么一周从周日开始到周六结束? Microsoft(C# 中的枚举)和 Apple(选择日期时的天数顺序)都是这样做的。
一周的第一天因枚举创建者遵循的不同文化或标准而异。
For Christian, the first day is Sunday regards to the bible
For standard ISO8601, the first day is Monday
http://www.timeanddate.com/calendar/days/
可在Windows地区和语言
中配置
这个维基百科 article 很好地解释了每周 7 天的文化方面以及它在不同地区的差异。这与您在一周中几天的枚举中看到的差异直接相关。
System First day of week Used by/in
ISO-8601 Monday EU and most of other European countries
(Islamic) Saturday Much of the Middle East
(North American) Sunday Canada, USA, Mexico, China, Japan
蓝色=星期日
黄色 = 星期一
绿色 = 星期六
一段时间以来,我一直致力于 class 处理重复性任务(例如提醒或日历中的计划事项)。我注意到在 C# 中,枚举的 int 值是: 周日 - 0 星期一 - 1 ... 周六 - 6
我在 OS X 的日历中也看到了同样的情况 - 让面板选择要安排的日期,它从第 1 位的星期日开始,然后是星期一,依此类推。
为什么?为什么一周从周日开始到周六结束? Microsoft(C# 中的枚举)和 Apple(选择日期时的天数顺序)都是这样做的。
一周的第一天因枚举创建者遵循的不同文化或标准而异。
For Christian, the first day is Sunday regards to the bible
For standard ISO8601, the first day is Monday
http://www.timeanddate.com/calendar/days/
可在Windows地区和语言
中配置这个维基百科 article 很好地解释了每周 7 天的文化方面以及它在不同地区的差异。这与您在一周中几天的枚举中看到的差异直接相关。
System First day of week Used by/in
ISO-8601 Monday EU and most of other European countries
(Islamic) Saturday Much of the Middle East
(North American) Sunday Canada, USA, Mexico, China, Japan
蓝色=星期日
黄色 = 星期一
绿色 = 星期六