Find which weekday any date in history or the future falls on.
The weekday is determined by parsing the date as a UTC midnight timestamp and reading its getUTCDay() value, which avoids timezone-induced off-by-one errors. The ISO 8601 week number is computed by finding the Thursday of the week the date belongs to — ISO weeks always start on Monday and week 1 is the week that contains January 4 (equivalently, the first Thursday of the year). The day-of-year is the ordinal count from January 1.
ISO Week 1 rule
Week 1 is the calendar week containing January 4th (or equivalently, the first Thursday of the year).
Day of year
Day of year = (date timestamp − Jan 0 timestamp) ÷ ms-per-day
ISO 8601 weeks run Monday to Sunday and are numbered 1–53. Week 1 is the first week that contains a Thursday, which means January 1 can be in week 52 or 53 of the previous year if it falls late in the week.
Yes. JavaScript's Date object handles the proleptic Gregorian calendar back to at least 100 AD for day-of-week calculations.
It's the ordinal position of the date within the calendar year. January 1 = day 1, December 31 = day 365 (or 366 in a leap year).
The last few days of December and the first few days of January can belong to the adjacent ISO year. For example, December 31, 2018 was in ISO week 1 of 2019.