Epidemiological weeks are just a standardized way to count weeks in a year. It’s a convenient grouping mechanism that allows for easy comparison in a year over year fashion. The CDC defines an epi week as seven days beginning on Sunday. The end of the week (Saturday for epi week, Sunday for ISO week) must land at least 4 days into the year. Another way to look at is, if the week is mostly in the new year, it goes with the new year.
package main
import (
"fmt"
"time"
"github.com/jmeekhof/epiweek"
)
func main() {
days := []epiweek.Epiweek{
epiweek.NewEpiweek(date(2019, 12, 31)),
epiweek.NewEpiweek(date(2020, 10, 15)),
epiweek.NewEpiweek(date(2020, 10, 16)),
epiweek.NewEpiweek(date(2020, 10, 17)),
epiweek.NewEpiweek(date(2020, 10, 18)),
epiweek.NewEpiweek(date(2020, 10, 19)),
epiweek.NewEpiweek(date(2020, 10, 20)),
epiweek.NewEpiweek(date(2020, 10, 21)),
epiweek.NewEpiweek(date(2020, 10, 22)),
}
for _, epi := range days {
year, week := epi.Epiweek()
fmt.Print("Year: ", year, " Week: ", week, "\n")
}
}