Skip to content

Latest commit

 

History

History
56 lines (44 loc) · 2.07 KB

README.adoc

File metadata and controls

56 lines (44 loc) · 2.07 KB

Epiweek Calculator

Build Status GoDoc Status Coverage Status Codecov.io Status

Simple week counter for weeks of the year. Often used in epidemiology. An epiweek is similar to an ISO week, except the epiwook starts on Sunday and ISO week begins on Monday.

Overview

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.

Basic Usage

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")
	}
}