Salma Hamed
Salma Hamed

Reputation: 2068

D3 time format skips isoWeek

When using d3.time.format(%Y%W) it doesn't give the expected output.

d3.time.format("%Y%W").parse("201553") outputs Mon Jan 04 2016

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.

Upvotes: 0

Views: 339

Answers (1)

Gerardo Furtado
Gerardo Furtado

Reputation: 102194

The number of weeks is zero-based. d3.time.format defines a week number that is different from ISO 8601.

Check the documentation: https://github.com/d3/d3/wiki/Time-Formatting

%W - week number of the year (Monday as the first day of the week) as a decimal number [00,53].

It's the same for %U:

%U - week number of the year (Sunday as the first day of the week) as a decimal number [00,53].

Upvotes: 1

Related Questions