timeless

A general purpose date(time) parser for R

https://github.com/schochastics/timeless

Science Score: 13.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
  • DOI references
  • Academic publication links
  • Academic email domains
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (17.1%) to scientific vocabulary

Keywords

datetime rstats rstats-package
Last synced: 6 months ago · JSON representation

Repository

A general purpose date(time) parser for R

Basic Info
Statistics
  • Stars: 22
  • Watchers: 3
  • Forks: 2
  • Open Issues: 1
  • Releases: 6
Topics
datetime rstats rstats-package
Created almost 2 years ago · Last pushed over 1 year ago
Metadata Files
Readme Changelog License

README.Rmd

---
output: github_document
---



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

# timeless 


[![R-CMD-check](https://github.com/schochastics/timeless/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/schochastics/timeless/actions/workflows/R-CMD-check.yaml)
[![CRAN status](https://www.r-pkg.org/badges/version/timeless)](https://CRAN.R-project.org/package=timeless)
[![Codecov test coverage](https://codecov.io/gh/schochastics/timeless/branch/main/graph/badge.svg)](https://app.codecov.io/gh/schochastics/timeless?branch=main)


A fast general purpose date/time converter written in Rust with crates [dateparser](https://github.com/waltzofpearls/dateparser) and [chrono](https://github.com/chronotope/chrono).

## Installation

You can install the development version of timeless like so:

``` r
remotes::install_github("schochastics/timeless")
#or
pak::pak("schochastics/timeless")
```

~~the package is also available on CRAN~~

```r
#install.packages("timeless")
```

**The fix I submitted for [#22](https://github.com/schochastics/timeless/issues/22) was apparently not sufficient and the package was archived.**

```{r}
library(timeless)
```

## Formats

timeless understands many different date(time) formats out of the box. A subset is included as a small benchmark dataset.
```{r}
bench_date
```

`chronos()` is the powerhouse of the package and tries as hard as possible to parse every input into either
a date or a datetime, depending on `out_format`. The function can also return a raw character vector which can be fed into faster
converters, such as [fasttime](https://github.com/s-u/fasttime).
```{r}
chronos(bench_date, out_format = "datetime")
```
## Functions

Under the hood `chronos()` calls three functions which can also be used in isolation:

- `parse_datetime()`: a fast datetime parser that tries several different formats until it can parse the input

- `parse_date()`: a fast date parser that tries several different formats until it can parse the input

- `parse_epoch()`: a fast-ish epoch timestamp parser

## other packages

[anytime](https://github.com/eddelbuettel/anytime) is the most accepted general purpose date(time) converter.

It does not recognize all accepted formats of `timeless` out of the box. (Note that the unrecognized formats can be added via `anytime::addFormats()`)
```{r}
sum_na <- function(x) sum(is.na(x))
sum_na(dplyr::coalesce(
    anytime::anytime(bench_date),
    anytime::anydate(bench_date)
)) / length(bench_date)
```

The list of formats supported out-of-the-box can be retrieved with `anytime::getFormats()`.
`timeless` implements these formats natively too.

Concerning runtime, `timeless` seems to be quite a bit faster than `anytime`.
```{r}
microbenchmark::microbenchmark(
    chronos(bench_date),
    anytime::anytime(bench_date)
)
```

See [this benchmark](https://github.com/schochastics/timeless/blob/main/data-raw/benchmark.md) for more details.

**Disclaimer**:  
While it might seem that `timeless` has an edge over `anytime`, it is far less battle tested and
mature. Date parsing can be very tricky. I am grateful for everyone who can take the package for a spin and report issues.

Owner

  • Name: David Schoch
  • Login: schochastics
  • Kind: user
  • Location: Germany
  • Company: cynkra

Data Scientist/DevOps Engineer at cynkra and #RStats developer

GitHub Events

Total
  • Issues event: 2
  • Watch event: 1
Last Year
  • Issues event: 2
  • Watch event: 1

Issues and Pull Requests

Last synced: 6 months ago

All Time
  • Total issues: 18
  • Total pull requests: 6
  • Average time to close issues: 20 days
  • Average time to close pull requests: about 4 hours
  • Total issue authors: 4
  • Total pull request authors: 3
  • Average comments per issue: 1.94
  • Average comments per pull request: 0.5
  • Merged pull requests: 6
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 2
  • Pull requests: 0
  • Average time to close issues: 5 months
  • Average time to close pull requests: N/A
  • Issue authors: 2
  • Pull request authors: 0
  • Average comments per issue: 0.5
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • schochastics (6)
  • chainsawriot (1)
  • eddelbuettel (1)
  • chrisumphlett (1)
Pull Request Authors
  • schochastics (4)
  • chainsawriot (2)
  • JosiahParry (2)
Top Labels
Issue Labels
Pull Request Labels

Packages

  • Total packages: 1
  • Total downloads:
    • cran 316 last-month
  • Total dependent packages: 0
  • Total dependent repositories: 0
  • Total versions: 6
  • Total maintainers: 1
cran.r-project.org: timeless

Fast General Purpose Date/Time Converter

  • Versions: 6
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 316 Last month
Rankings
Dependent packages count: 28.1%
Dependent repos count: 36.1%
Average: 49.7%
Downloads: 84.9%
Maintainers (1)
Last synced: 11 months ago

Dependencies

.github/workflows/R-CMD-check.yaml actions
  • actions/checkout v4 composite
  • r-lib/actions/check-r-package v2 composite
  • r-lib/actions/setup-pandoc v2 composite
  • r-lib/actions/setup-r v2 composite
  • r-lib/actions/setup-r-dependencies v2 composite
.github/workflows/pkgdown.yaml actions
  • JamesIves/github-pages-deploy-action v4.5.0 composite
  • actions/checkout v4 composite
  • r-lib/actions/setup-pandoc v2 composite
  • r-lib/actions/setup-r v2 composite
  • r-lib/actions/setup-r-dependencies v2 composite
.github/workflows/test-coverage.yaml actions
  • actions/checkout v4 composite
  • actions/upload-artifact v4 composite
  • r-lib/actions/setup-r v2 composite
  • r-lib/actions/setup-r-dependencies v2 composite
src/rust/Cargo.lock cargo
  • aho-corasick 1.1.2
  • android-tzdata 0.1.1
  • android_system_properties 0.1.5
  • anyhow 1.0.80
  • autocfg 1.1.0
  • bumpalo 3.15.3
  • cc 1.0.88
  • cfg-if 1.0.0
  • chrono 0.4.34
  • core-foundation-sys 0.8.6
  • dateparser 0.2.1
  • extendr-api 0.6.0
  • extendr-macros 0.6.0
  • iana-time-zone 0.1.60
  • iana-time-zone-haiku 0.1.2
  • js-sys 0.3.68
  • lazy_static 1.4.0
  • libR-sys 0.6.0
  • libc 0.2.153
  • log 0.4.21
  • memchr 2.7.1
  • num-traits 0.2.18
  • once_cell 1.19.0
  • paste 1.0.14
  • proc-macro2 1.0.78
  • quote 1.0.35
  • regex 1.10.3
  • regex-automata 0.4.5
  • regex-syntax 0.8.2
  • syn 2.0.52
  • unicode-ident 1.0.12
  • wasm-bindgen 0.2.91
  • wasm-bindgen-backend 0.2.91
  • wasm-bindgen-macro 0.2.91
  • wasm-bindgen-macro-support 0.2.91
  • wasm-bindgen-shared 0.2.91
  • windows-core 0.52.0
  • windows-targets 0.52.4
  • windows_aarch64_gnullvm 0.52.4
  • windows_aarch64_msvc 0.52.4
  • windows_i686_gnu 0.52.4
  • windows_i686_msvc 0.52.4
  • windows_x86_64_gnu 0.52.4
  • windows_x86_64_gnullvm 0.52.4
  • windows_x86_64_msvc 0.52.4
src/rust/Cargo.toml cargo
DESCRIPTION cran
  • R >= 3.6 depends
  • testthat >= 3.0.0 suggests