MongoDB manual指出 strftime
中的 $week
聚合和 %U
运算符的工作方式如下:
Returns the week of the year for a date as a number between 0 and 53.
Weeks begin on Sundays, and week 1 begins with the first Sunday of the year. Days preceding the first Sunday of the year are in week 0. This behavior is the same as the “%U” operator to the strftime standard library function.
最佳答案
没有。 ISO 8601没有第 0 周。
根据标准:
The ISO 8601 definition for week 01 is the week with the year's first Thursday in it.
...
- If 1 January is on a Monday, Tuesday, Wednesday or Thursday, it is in week 01;
- If 1 January is on a Friday, it is part of week 53 of the previous year;
- If on a Saturday, it is part of week 52 (or 53 if the previous year was a leap year);
- If on a Sunday, it is part of week 52 of the previous year.
有一个开放的票证建议添加其他周计数选项;评论中有对 $isoweek
的建议:
关于mongodb - MongoDB 年度周是否符合 ISO 8601 标准?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33654063/