Skip to contents

cstime provides date time functions for public health purposes.

The core functionality is consistent time conversion between :

  • Date.
  • Isoyear, isoweek, isoyearweek.
  • Season week.

It also provides functions to generate rolling dates for computing the weekly, bi-weekly, 4 week averages.

cstime is part of the csverse package suite.

library(cstime)
#> cstime 2024.6.13
#> https://www.csids.no/cstime/
library(magrittr)

To convert a date to isoyear:

date_to_isoyear_c('2021-01-01')
#> [1] "2020"

To convert a isoyearweek string to isoyear/isoweek:

isoyearweek_to_isoyear_c("2021-02")
#> [1] "2021"
isoyearweek_to_isoweek_c("2021-02")
#> [1] "02"

To convert a season week to isoweek (and reverse):