clock

A Date-Time Library for R

https://github.com/r-lib/clock

Science Score: 26.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (16.9%) to scientific vocabulary

Keywords from Contributors

tidy-data data-manipulation grammar graph-functions network-graph property-graph reproducibility tidyverse package-creation
Last synced: 10 months ago · JSON representation

Repository

A Date-Time Library for R

Basic Info
  • Host: GitHub
  • Owner: r-lib
  • License: other
  • Language: R
  • Default Branch: main
  • Homepage: https://clock.r-lib.org
  • Size: 12.2 MB
Statistics
  • Stars: 109
  • Watchers: 5
  • Forks: 8
  • Open Issues: 22
  • Releases: 13
Created over 5 years ago · Last pushed about 1 year ago
Metadata Files
Readme Changelog License Code of conduct

README.Rmd

---
output: github_document
editor_options:
  chunk_output_type: console
---



```{r, include = FALSE}
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "man/figures/README-",
  out.width = "100%"
)
```

# clock 


[![Codecov test coverage](https://codecov.io/gh/r-lib/clock/graph/badge.svg)](https://app.codecov.io/gh/r-lib/clock)
[![R-CMD-check](https://github.com/r-lib/clock/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/r-lib/clock/actions/workflows/R-CMD-check.yaml)


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:

-   Provides a new family of date-time classes (durations, time points, zoned-times, and calendars) that partition responsibilities so that you only have to think about time zones when you need them.

-   Implements a high level API for R's native date (Date) and date-time (POSIXct) classes that lets you get productive quickly without having to learn the details of clock's new date-time types.

-   Requires explicit handling of invalid dates (e.g. what date is one month after January 31st?) and nonexistent or ambiguous times (caused by daylight saving time issues).

-   Is built on the C++ [date](https://github.com/HowardHinnant/date) library, which provides a correct and high-performance backend.

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.

-   A *duration* counts units of time, like "5 years" or "6 nanoseconds".
    Bigger units are defined in terms of seconds, i.e. 1 day is 86400 seconds and 1 year is 365.2425 days.
    Durations are important because they form the backbone of clock; it's relatively rare to use them directly.

-   A *time point* records an instant in time, like "1:24pm January 1st 2015".
    It combines a *duration* with a "clock" that defines when to start counting and what exactly to count.
    There are two important types of time in clock: sys-time and naive-time.
    They're equivalent until you start working with zoned-times.

-   A *zoned-time* is a time point paired with a time zone.
    You can create them from either a sys-time or a naive-time, depending on whether you want to convert the time point from UTC (leaving the underlying duration unchanged, but changing the printed time), or declare that the time point is in a specific time zone (leaving the printed time unchanged, but changing the underlying duration).
    Zoned-times are primarily needed for communication with humans.

-   A *calendar* represents a date using a combination of fields like year-month-day, year-month-weekday, year-quarter-day, year-day, or iso-year-week-day, along with hour/minute/second fields to represent time within a day (so they're similar to R's POSIXlt).
    Calendar objects are extremely efficient at arithmetic involving irregular periods such as months, quarters, and years and at getting and setting specified components.
    A calendar can represent invalid dates (like 2020-02-31) which only need to be resolved when converting back to a time point.

## Installation

Install the released version from [CRAN](https://CRAN.R-project.org) with:

``` r
install.packages("clock")
```

Install the development version from [GitHub](https://github.com/) with:

``` r
# 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](https://clock.r-lib.org/reference/index.html#section-high-level-api) section of the pkgdown reference page.

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

-   [Getting Started](https://clock.r-lib.org/articles/clock.html)

-   [Motivations for clock](https://clock.r-lib.org/articles/articles/motivations.html)

-   [Examples and Recipes](https://clock.r-lib.org/articles/recipes.html)

-   [Frequently Asked Questions](https://clock.r-lib.org/articles/faq.html)

You can also watch this [5 minute lightning talk](https://www.youtube.com/watch?v=DPU7TJZXWvo) about clock:

## Acknowledgments The ideas used to build clock have come from a number of places: - First and foremost, clock depends on and is inspired by the [date](https://github.com/HowardHinnant/date) library by Howard Hinnant, a variant of which has been voted in to C++20. - The R "record" types that clock is built on come from [vctrs](https://github.com/r-lib/vctrs). - The [nanotime](https://github.com/eddelbuettel/nanotime) package was the first to implement a nanosecond resolution time type for R. - The [zoo](https://CRAN.R-project.org/package=zoo) package was the first to implement year-month and year-quarter types, and has functioned as a very successful time series infrastructure package for many years. 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()`.

Owner

  • Name: R infrastructure
  • Login: r-lib
  • Kind: organization

GitHub Events

Total
  • Create event: 9
  • Release event: 1
  • Issues event: 10
  • Watch event: 8
  • Delete event: 7
  • Issue comment event: 5
  • Push event: 46
  • Pull request event: 17
  • Fork event: 2
Last Year
  • Create event: 9
  • Release event: 1
  • Issues event: 10
  • Watch event: 8
  • Delete event: 7
  • Issue comment event: 5
  • Push event: 46
  • Pull request event: 17
  • Fork event: 2

Committers

Last synced: 12 months ago

All Time
  • Total Commits: 1,038
  • Total Committers: 6
  • Avg Commits per committer: 173.0
  • Development Distribution Score (DDS): 0.005
Past Year
  • Commits: 39
  • Committers: 3
  • Avg Commits per committer: 13.0
  • Development Distribution Score (DDS): 0.051
Top Committers
Name Email Commits
DavisVaughan d****s@r****m 1,033
Trevor L Davis t****s@g****m 1
Michael Chirico m****4@g****m 1
Marta Alcalde-Herraiz 9****e 1
Lionel Henry l****y@g****m 1
Jennifer (Jenny) Bryan j****n@g****m 1
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 10 months ago

All Time
  • Total issues: 87
  • Total pull requests: 66
  • Average time to close issues: 5 months
  • Average time to close pull requests: 5 days
  • Total issue authors: 30
  • Total pull request authors: 5
  • Average comments per issue: 1.82
  • Average comments per pull request: 0.18
  • Merged pull requests: 60
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 6
  • Pull requests: 20
  • Average time to close issues: 13 days
  • Average time to close pull requests: 7 days
  • Issue authors: 4
  • Pull request authors: 3
  • Average comments per issue: 0.5
  • Average comments per pull request: 0.2
  • Merged pull requests: 15
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • DavisVaughan (45)
  • TimTaylor (5)
  • eitsupi (4)
  • clairerichardsRN (3)
  • trevorld (2)
  • Henrik-P (2)
  • cgoo4 (1)
  • EmilHvitfeldt (1)
  • jido (1)
  • matiasandina (1)
  • jwilliman (1)
  • mmollayi (1)
  • RalphJO (1)
  • m-muecke (1)
  • wurli (1)
Pull Request Authors
  • DavisVaughan (57)
  • martaalcalde (2)
  • eitsupi (2)
  • MichaelChirico (2)
  • trevorld (1)
Top Labels
Issue Labels
feature (21) bug (4) documentation (3) upkeep (1) tidy-dev-day :nerd_face: (1)
Pull Request Labels

Packages

  • Total packages: 1
  • Total downloads:
    • cran 129,921 last-month
  • Total docker downloads: 33,638,050
  • Total dependent packages: 8
  • Total dependent repositories: 20
  • Total versions: 13
  • Total maintainers: 1
cran.r-project.org: clock

Date-Time Types and Tools

  • Versions: 13
  • Dependent Packages: 8
  • Dependent Repositories: 20
  • Downloads: 129,921 Last month
  • Docker Downloads: 33,638,050
Rankings
Downloads: 1.2%
Stargazers count: 4.1%
Dependent repos count: 6.2%
Dependent packages count: 6.5%
Average: 8.3%
Forks count: 12.4%
Docker downloads count: 19.3%
Maintainers (1)
Last synced: 11 months ago

Dependencies

DESCRIPTION cran
  • R >= 3.4 depends
  • rlang >= 1.0.4 imports
  • tzdb >= 0.3.0 imports
  • vctrs >= 0.4.1 imports
  • covr * suggests
  • knitr * suggests
  • magrittr * suggests
  • pillar * suggests
  • rmarkdown * suggests
  • testthat >= 3.0.0 suggests
  • withr * suggests
.github/workflows/R-CMD-check.yaml actions
  • actions/cache v2 composite
  • actions/checkout v2 composite
  • actions/upload-artifact main composite
  • r-lib/actions/setup-pandoc v1 composite
  • r-lib/actions/setup-r v1 composite
.github/workflows/pkgdown.yaml actions
  • actions/cache v2 composite
  • actions/checkout v2 composite
  • r-lib/actions/setup-pandoc v1 composite
  • r-lib/actions/setup-r v1 composite
.github/workflows/pr-commands.yaml actions
  • actions/checkout v2 composite
  • r-lib/actions/pr-fetch v1 composite
  • r-lib/actions/pr-push v1 composite
  • r-lib/actions/setup-r v1 composite
.github/workflows/test-coverage.yaml actions
  • actions/cache v2 composite
  • actions/checkout v2 composite
  • r-lib/actions/setup-r v1 composite