D3时间格式跳过isoWeek [英] D3 time format skips isoWeek
问题描述
使用d3.time.format(%Y%W)时,不会给出预期的输出。
When using d3.time.format(%Y%W) it doesn't give the expected output.
d3.time。 format(%Y%W)。parse( 201553)
输出
2016年1月4日
尽管2015年第53周的第一个星期一是 2015年12月28日星期一
Although the first Monday of week number 53 in 2015 is Mon Dec 28 2015
所以它似乎可以解析到下周。
So it seems like it parses to the next week.
任何想法都可以解决此问题以获得预期的输出。
Any ideas how to fix this to get the expected output.
推荐答案
周数从零开始。 d3.time.format
定义了不同于ISO 8601的星期数。
The number of weeks is zero-based. d3.time.format
defines a week number that is different from ISO 8601.
检查文档: https://github.com/d3/d3/wiki/Time-Formatting
%W-一年中的第几周(星期一为一周的第一天),以十进制数[00,53]。
%W - week number of the year (Monday as the first day of the week) as a decimal number [00,53].
%U
相同:
%U-一年中的第几周(星期日为一周的第一天),以十进制数[00,53]。
%U - week number of the year (Sunday as the first day of the week) as a decimal number [00,53].
这篇关于D3时间格式跳过isoWeek的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!