Skip to main content
100%

Counting Weekdays

✓ Published0🌍 Public
Mmbostock
Last edited Jun 20, 2013
Created on Jun 20, 2013

This example demonstrates how to count the number of weekdays between any date and January 1, 1970, using the custom `weekday` function, which also provides an `invert` method to reverse the calculation. The code defines helper functions `weekdaysInYear` and `weekdayOfYear` to compute weekday totals per year and per date, accounting for skipped weekends. It relies on the D3.js library’s `d3.time` methods, such as `d3.time.dayOfYear` and `d3.time.year`, to extract day-of-year and year information from JavaScript `Date` objects, enabling accurate weekday arithmetic without external data.

AI-generated description

Similar vizzes