clock

Codecov test coverage R-CMD-check

clock is an R package for working with date-times. It is packed with features, including utilities for: parsing, formatting, arithmetic, rounding, and extraction/updating of individual components. In addition to these tools for manipulating date-times, clock provides entirely new date-time types which are structured to reduce the agony of working with time zones as much as possible. At a high-level, clock:

There are four key classes in clock, inspired by the design of the C++ date and chrono libraries. Some types are more efficient than others at particular operations, and it is only when all 4 are taken as a whole do you get a complete date time library.

Installation

Install the released version from CRAN with:

install.packages("clock")

Install the development version from GitHub with:

# install.packages("pak")
pak::pak("r-lib/clock")

Learning

With clock, there is a high-level API for manipulating R’s native date and date-time types (Date, POSIXct, and POSIXlt), as well as a low-level API for more advanced date-time manipulations. The high-level API should allow you to quickly get productive with clock without having to learn many of the new types. An easy way to get an overview of this is by looking at the High Level API section of the pkgdown reference page.

You’ll also want to take a look at clock’s vignettes:

You can also watch this 5 minute lightning talk about clock:

Acknowledgments

The ideas used to build clock have come from a number of places:

Additionally, I’d like to thank my wife for being a power user of clock, and having a number of discussions with me around bugs and missing features. You can thank her for date_count_between().