{"id":14069291,"url":"https://github.com/shrektan/ymd","last_synced_at":"2026-02-26T12:02:26.568Z","repository":{"id":56934278,"uuid":"443802143","full_name":"shrektan/ymd","owner":"shrektan","description":"An R package that handles common dates operations using Rust","archived":false,"fork":false,"pushed_at":"2025-04-15T05:35:05.000Z","size":90726,"stargazers_count":34,"open_issues_count":3,"forks_count":3,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-12-31T05:13:21.316Z","etag":null,"topics":["r","rextendr","rust","ymd"],"latest_commit_sha":null,"homepage":"https://shrektan.github.io/ymd/","language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/shrektan.png","metadata":{"files":{"readme":"README.Rmd","changelog":"NEWS.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-01-02T15:36:14.000Z","updated_at":"2025-10-06T09:37:54.000Z","dependencies_parsed_at":"2025-01-02T02:15:39.034Z","dependency_job_id":null,"html_url":"https://github.com/shrektan/ymd","commit_stats":{"total_commits":131,"total_committers":2,"mean_commits":65.5,"dds":0.007633587786259555,"last_synced_commit":"f1d9398a03b9374c018e486d646777ce2339fadc"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/shrektan/ymd","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shrektan%2Fymd","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shrektan%2Fymd/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shrektan%2Fymd/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shrektan%2Fymd/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/shrektan","download_url":"https://codeload.github.com/shrektan/ymd/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shrektan%2Fymd/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29858461,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-26T08:51:08.701Z","status":"ssl_error","status_checked_at":"2026-02-26T08:50:19.607Z","response_time":89,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["r","rextendr","rust","ymd"],"created_at":"2024-08-13T07:06:48.945Z","updated_at":"2026-02-26T12:02:26.561Z","avatar_url":"https://github.com/shrektan.png","language":"R","funding_links":[],"categories":["Rust"],"sub_categories":[],"readme":"---\noutput: github_document\n---\n\n\u003c!-- README.md is generated  from README.Rmd. Please edit that file --\u003e\n\n```{r, include = FALSE}\nknitr::opts_chunk$set(\n  collapse = TRUE,\n  comment = \"#\u003e\",\n  fig.path = \"man/figures/README-\",\n  out.width = \"100%\"\n)\n```\n\n# ymd\n\n\u003c!-- badges: start --\u003e\n[![R-CMD-check](https://github.com/shrektan/ymd/workflows/R-CMD-check/badge.svg)](https://github.com/shrektan/ymd/actions)\n[![CRAN status](https://www.r-pkg.org/badges/version/ymd)](https://CRAN.R-project.org/package=ymd)\n[![Downloads from the RStudio CRAN mirror](https://cranlogs.r-pkg.org/badges/ymd)](https://cran.r-project.org/package=ymd)\n[![Rust Code Coverage](https://coveralls.io/repos/github/shrektan/ymd/badge.svg?branch=main)](https://coveralls.io/github/shrektan/ymd?branch=main)\n\u003c!-- badges: end --\u003e\n\nConvert 'YMD' format number or string to Date efficiently, e.g., `211225` to `as.Date(\"2021-12-25\")`, using Rust's standard library.\nIt also provides helper functions to handle Date, e.g., quick finding the beginning or end of the given period, adding months to Date, etc.\n\nIt's similar to the `lubridate` package but is much lighter and focuses only on Date objects.\n\n## Installation\n\n### Binary version (no Rust toolchain required)\n\nCRAN provides the binary package. So, if you are on Windows or macOS, the package can be installed via:\n\n```r\ninstall.packages(\"ymd\")\n```\n\nIf you are on Linux, you can try to use the [RSPM (RStudio Package Manager) repo](https://packagemanager.rstudio.com)\nprovided by RStudio PBC, via (remember to choose the correct binary repo URL for your platform):\n\n```r\ninstall.packages(\"ymd\", repos = \"{RSPM-Repo-URL}\")\n```\n\n### Source version (Rust toolchain required)\n\nIf you want to build the dev version from source, you'll need the Rust toolchain, which\ncan be installed following [the instructions from the Rust book](https://doc.rust-lang.org/book/ch01-01-installation.html).\n\nAfter that, you can build the package via:\n\n```r\nremotes::install_github(\"ymd\")\n```\n\n## Use Cases and Benchmarks\n\n```{r setup}\nprint_bmk \u003c- function(x) {\n  x[[1]] \u003c- format(x[[1]])\n  x[[5]] \u003c- format(x[[5]])\n  rnd \u003c- \\(v) if (is.numeric(v)) round(v, 1) else v\n  x[, 1:8] |\u003e\n    lapply(rnd) |\u003e\n    as.data.frame() |\u003e\n    knitr::kable() |\u003e\n    print()\n}\nrun_bmk \u003c- function(..., time_unit = \"us\") {\n  bench::mark(..., time_unit = time_unit) |\u003e print_bmk()\n}\n```\n\n### ymd\n\n```{r ymd, results='asis'}\nx \u003c- c(\"210101\", \"21/02/03\", \"89-1-03\", \"1989.03.05\", \"01 02 03\")\nx \u003c- rep(x, 100)\nrun_bmk(\n  ymd::ymd(x),\n  lubridate::ymd(x)\n)\n\nx \u003c- c(210101, 210224, 211231, 19890103)\nx \u003c- rep(x, 100)\nrun_bmk(\n  ymd::ymd(x),\n  lubridate::ymd(x)\n)\n\nx \u003c- c(\"2021-01-01\", \"2022-12-31\", \"1995-03-22\")\nx \u003c- rep(x, 100)\nrun_bmk(\n  ymd::ymd(x),\n  lubridate::ymd(x),\n  as.Date(x)\n)\n\nx \u003c- ymd::ymd(210515) + 1:100\nrun_bmk(\n  ymd::eop$tm(x),\n  lubridate::ceiling_date(x, \"month\") - 1\n)\n```\n\n\n### edate\n\n```{r edate, results='asis'}\n`%m+%` \u003c- lubridate::`%m+%`\nx \u003c- ymd::ymd(c(200115, 200131, 200229, 200331, 200401))\nx \u003c- rep(x, 100)\nrun_bmk(\n  ymd::edate(x, 2),\n  x %m+% months(2)\n)\nrun_bmk(\n  ymd::edate(x, -12),\n  x %m+% months(-12)\n)\n```\n\n### Extract Date Part\n\n```{r date-part, results='asis'}\n# tweak from https://github.com/Rdatatable/data.table/pull/5300\nset.seed(373L)\nx \u003c- as.Date(data.table::as.IDate(sample(seq(-25000, 45000), 1e6, TRUE)))\n\nrun_bmk(\n  data.table::year(x),\n  lubridate::year(x),\n  funchir::quick_year(x),\n  ymd::year(x)\n)\nrun_bmk(\n  data.table::month(x),\n  lubridate::month(x),\n  ymd::month(x)\n)\nrun_bmk(\n  data.table::quarter(x),\n  lubridate::quarter(x),\n  ymd::quarter(x)\n)\nrun_bmk(\n  data.table::yday(x),\n  lubridate::yday(x),\n  funchir::quick_yday(x),\n  ymd::yday(x)\n)\nrun_bmk(\n  data.table::mday(x),\n  lubridate::mday(x),\n  funchir::quick_mday(x),\n  ymd::mday(x)\n)\nrun_bmk(\n  data.table::wday(x),\n  lubridate::wday(x),\n  ymd::wday(x)\n)\nrun_bmk(\n  data.table::isoweek(x),\n  lubridate::isoweek(x),\n  ymd::isoweek(x)\n)\n```\n\n## Session Info\n\n```{r session-info}\nxfun::session_info()\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshrektan%2Fymd","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshrektan%2Fymd","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshrektan%2Fymd/lists"}