mongodb - MongoDB 年度周是否符合 ISO 8601 标准?

标签 mongodb iso8601

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 week of the year standard

最佳答案

没有。 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 的建议:

https://jira.mongodb.org/browse/SERVER-7695

关于mongodb - MongoDB 年度周是否符合 ISO 8601 标准?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33654063/

相关文章:

Mongodb - 查找耦合文档,其中 A 跟随 B,B 跟随 A

ruby - 强制 Ruby Time 类使用 ISO8601

java - 用 Joda-Time 解析周日期?

javascript - JavaScript 中的 JSON ISO8601 解析

string - 在Elasticsearch中对关键字查询的句子

mongodb - 合并MongoDb客户端: pyMongo and MongoEngine

javascript - 有没有办法从 Mongoose 模式中获取所有唯一的数组值?

mongodb - "Error: couldn' t 在 Windows 上使用 secret 文件在 MongoDB docker 堆栈中添加用户

java - ISO 时间出现意外输出 (8601)

python - Unix 时间戳转 ISO 8601 时间格式