Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@mbostock
mbostock / weekday.js
Last active November 30, 2020 09:49
Counting Weekdays
weekday = (function() {
// Returns the weekday number for the given date relative to January 1, 1970.
function weekday(date) {
var weekdays = weekdayOfYear(date),
year = date.getFullYear();
while (--year >= 1970) weekdays += weekdaysInYear(year);
return weekdays;
}