{"id":13401094,"url":"https://github.com/eddelbuettel/anytime","last_synced_at":"2025-04-04T12:10:26.323Z","repository":{"id":49905980,"uuid":"67568035","full_name":"eddelbuettel/anytime","owner":"eddelbuettel","description":"Anything to POSIXct or Date Converter","archived":false,"fork":false,"pushed_at":"2024-08-02T01:14:09.000Z","size":3142,"stargazers_count":162,"open_issues_count":0,"forks_count":18,"subscribers_count":12,"default_branch":"master","last_synced_at":"2024-10-12T21:26:24.483Z","etag":null,"topics":["boost","c-plus-plus-11","conversions","cpp11","cran","date","datetime","posixct","r","rcpp"],"latest_commit_sha":null,"homepage":"https://eddelbuettel.github.io/anytime","language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/eddelbuettel.png","metadata":{"files":{"readme":"README.md","changelog":"ChangeLog","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":"2016-09-07T03:18:53.000Z","updated_at":"2024-09-14T08:04:33.000Z","dependencies_parsed_at":"2024-01-18T11:03:56.744Z","dependency_job_id":"f08c8112-8a2e-4550-a4f4-e460792415be","html_url":"https://github.com/eddelbuettel/anytime","commit_stats":{"total_commits":376,"total_committers":6,"mean_commits":"62.666666666666664","dds":0.02393617021276595,"last_synced_commit":"f91ecd4265566a6cea5eb77fa81f7c6c8d564060"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eddelbuettel%2Fanytime","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eddelbuettel%2Fanytime/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eddelbuettel%2Fanytime/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eddelbuettel%2Fanytime/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/eddelbuettel","download_url":"https://codeload.github.com/eddelbuettel/anytime/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247174456,"owners_count":20896078,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["boost","c-plus-plus-11","conversions","cpp11","cran","date","datetime","posixct","r","rcpp"],"created_at":"2024-07-30T19:00:58.621Z","updated_at":"2025-04-04T12:10:26.297Z","avatar_url":"https://github.com/eddelbuettel.png","language":"R","funding_links":[],"categories":["R"],"sub_categories":[],"readme":"## anytime: Anything to 'POSIXct' or 'Date' Converter\n\n[![CI](https://github.com/eddelbuettel/anytime/workflows/ci/badge.svg)](https://github.com/eddelbuettel/anytime/actions?query=workflow%3Aci)\n[![License](https://eddelbuettel.github.io/badges/GPL2+.svg)](https://www.gnu.org/licenses/gpl-2.0.html)\n[![CRAN](https://www.r-pkg.org/badges/version/anytime)](https://cran.r-project.org/package=anytime)\n[![r-universe](https://eddelbuettel.r-universe.dev/badges/anytime)](https://eddelbuettel.r-universe.dev/anytime)\n[![Dependencies](https://tinyverse.netlify.app/badge/anytime)](https://cran.r-project.org/package=anytime)\n[![CRAN use](https://jangorecki.gitlab.io/rdeps/anytime/CRAN_usage.svg?sanitize=true)](https://cran.r-project.org/package=anytime)\n[![Downloads (monthly)](https://cranlogs.r-pkg.org/badges/anytime?color=brightgreen)](https://www.r-pkg.org/pkg/anytime)\n[![Downloads (total)](https://cranlogs.r-pkg.org/badges/grand-total/anytime?color=brightgreen)](https://www.r-pkg.org/pkg/anytime)\n[![Code Coverage](https://codecov.io/gh/eddelbuettel/anytime/graph/badge.svg)](https://app.codecov.io/gh/eddelbuettel/anytime)\n[![Last Commit](https://img.shields.io/github/last-commit/eddelbuettel/anytime)](https://github.com/eddelbuettel/anytime)\n[![DOI](https://img.shields.io/badge/doi-10.32614/CRAN.package.anytime-blue)](https://doi.org/10.32614/CRAN.package.anytime)\n[![Documentation](https://img.shields.io/badge/documentation-is_here-blue)](https://eddelbuettel.github.io/anytime/)\n[![JOSS](https://img.shields.io/badge/JOSS-Not%20Worthy-lightgrey)](https://github.com/openjournals/joss-reviews/issues/1605#issuecomment-517055652)\n\n### Motivation\n\nR excels at computing with dates, and times.  Using _typed_ representation for your data is highly\nrecommended not only because of the functionality offered but also because of the added safety\nstemming from proper representation.\n\nBut there is a small nuisance cost in interactive work as well as in programming. Users must have\ntold `as.POSIXct()` about a million times that the origin is (of course) the\n[epoch](https://en.wikipedia.org/wiki/Unix_time). Do we really have to say it a million more times?\nSimilarly, when parsing dates that are _some form_ of YYYYMMDD format, do we really have to manually\nconvert from `integer` or `numeric` or `factor` or `ordered` to character? Having one of several\ncommon separators and/or date / time month forms (YYYY-MM-DD, YYYY/MM/DD, YYYYMMDD, YYYY-mon-DD and\nso on, with or without times), do we really need a format string? Or could a smart converter\nfunction do this?\n\n`anytime()` aims to be that _general purpose_ converter returning a proper `POSIXct` (or `Date`)\nobject no matter the input (provided it was somewhat parseable), relying on\n[Boost date_time](https://www.boost.org/doc/libs/1_61_0/doc/html/date_time.html) for the (efficient,\nperformant) conversion. `anydate()` is an additional wrapper returning a `Date` object instead.\n\n### Documentation\n\nPackage documentation, help pages, a vignette, and more is available\n[here](https://eddelbuettel.github.io/anytime/).\n\n### Examples\n\nWe show some simple examples on `Date` types.\n\n(Note that in the first few examples, and for numeric conversion in this range we now\nonly use `anydate` as `anytime` is consistent in computing seconds since epoch. If you want the\nbehaviour of version older than 0.3.0, set `oldHeuristic=TRUE`, see `help(anytime)` for more.)\n\n#### From Integer or Numeric or Factor or Ordered\n\n```r\nlibrary(anytime)                      ## also caches TZ in local env\noptions(digits.secs=6)                ## for fractional seconds below\n\n## integer\nanydate(20160101L + 0:2)              ## older version used anytime for this too\n[1] \"2016-01-01 CST\" \"2016-01-02 CST\" \"2016-01-03 CST\"\n\n## numeric\nanydate(20160101 + 0:2)\n[1] \"2016-01-01 CST\" \"2016-01-02 CST\" \"2016-01-03 CST\"\n\n## factor\nanydate(as.factor(20160101 + 0:2))\n[1] \"2016-01-01 CST\" \"2016-01-02 CST\" \"2016-01-03 CST\"\n\n## ordered\nanydate(as.ordered(20160101 + 0:2))\n[1] \"2016-01-01 CST\" \"2016-01-02 CST\" \"2016-01-03 CST\"\n```\n\n#### Character: Simple\n\n```r\n## Dates: Character\nanydate(as.character(20160101 + 0:2))\n[1] \"2016-01-01 CST\" \"2016-01-02 CST\" \"2016-01-03 CST\"\n\n## Dates: alternate formats\nanydate(c(\"20160101\", \"2016/01/02\", \"2016-01-03\"))\n[1] \"2016-01-01 CST\" \"2016-01-02 CST\" \"2016-01-03 CST\"\n```\n\n#### Character: ISO\n\n```r\n## Datetime: ISO with/without fractional seconds\nanytime(c(\"2016-01-01 10:11:12\", \"2016-01-01 10:11:12.345678\"))\n[1] \"2016-01-01 10:11:12.000000 CST\" \"2016-01-01 10:11:12.345678 CST\"\n\n## Datetime: ISO alternate (?) with 'T' separator\nanytime(c(\"20160101T101112\", \"20160101T101112.345678\"))\n[1] \"2016-01-01 10:11:12.000000 CST\" \"2016-01-01 10:11:12.345678 CST\"\n```\n\n#### Character: Textual month formats\n\n```r\n## ISO style\nanytime(c(\"2016-Sep-01 10:11:12\", \"Sep/01/2016 10:11:12\", \"Sep-01-2016 10:11:12\"))\n[1] \"2016-09-01 10:11:12 CDT\" \"2016-09-01 10:11:12 CDT\" \"2016-09-01 10:11:12 CDT\"\n\n## Datetime: Mixed format (cf https://stackoverflow.com/questions/39259184)\nanytime(c(\"Thu Sep 01 10:11:12 2016\", \"Thu Sep 01 10:11:12.345678 2016\"))\n[1] \"2016-09-01 10:11:12.000000 CDT\" \"2016-09-01 10:11:12.345678 CDT\"\n```\n\n\n#### Character: Dealing with DST\n\nThis shows an important aspect. When not working localtime (by overriding to `UTC`) the _changing\ndifference_ UTC is correctly covered (which the underlying\n[Boost Date_Time](https://www.boost.org/doc/libs/1_61_0/doc/html/date_time.html) library does not by\nitself).\n\n\n```r\n## Datetime: pre/post DST\nanytime(c(\"2016-01-31 12:13:14\", \"2016-08-31 12:13:14\"))\n[1] \"2016-01-31 12:13:14 CST\" \"2016-08-31 12:13:14 CDT\"\nanytime(c(\"2016-01-31 12:13:14\", \"2016-08-31 12:13:14\"), tz=\"UTC\")  # important: catches change\n[1] \"2016-01-31 18:13:14 UTC\" \"2016-08-31 17:13:14 UTC\"\n```\n\n### Technical Details\n\nThe heavy lifting is done by a combination of\n[Boost lexical_cast](https://www.boost.org/doc/libs/1_70_0/doc/html/boost_lexical_cast.html) to go\nfrom _anything_ to string representation which is then parsed by\n[Boost Date_Time](https://www.boost.org/doc/libs/1_70_0/doc/html/date_time.html).  We use the\n[BH package](https://dirk.eddelbuettel.com/code/bh.html) to access [Boost](https://www.boost.org), and\nrely on [Rcpp](https://dirk.eddelbuettel.com/code/rcpp.html) for a seamless C++ interface to and from\n[R](https://www.r-project.org).\n\nFurther, as the [Boost\nDate_Time](https://www.boost.org/doc/libs/1_70_0/doc/html/date_time.html)\nlibrary cannot resolve timezones on the Windows platform (where timezone information is typically provided by R itself for its use), we offer a fallback of calling into R (via facilities from\n[Rcpp](https://dirk.eddelbuettel.com/code/rcpp.html)); see the help for\nthe `useR` argument for more details.\n\n### Status\n\nThe package should work as expected.\n\n### Example Uses\n\nSeveral different [CRAN](https://cran.r-project.org)\npackages import this package. Among them are the following research-focused\npackages:\n\n - [adheRenceRX](https://cran.r-project.org/package=adheRenceRX) by Beal assesses medication adherence;\n - [AGread](https://cran.r-project.org/package=AGread) by Hibbing _et al_ which reads and transforms ActiGraph physical activity measures;\n - [cqcr](https://cran.r-project.org/package=AGread) by Odell accesses 'Care Quality Commission' data from the health and adult social care regulator for England;\n - [datadogr](https://cran.r-project.org/package=datadogr) by Yutani queries metrics from Datadog;\n - [E4tools](https://cran.r-project.org/package=E4tools) by Kleiman which reads data from Empatica wearable physiology monitors;\n - [nprcgenekeepr](https://cran.r-project.org/package=nprcgenekeepr) by Raboin _et al_ provides genetic tools for colony management ;\n - [RDS](https://cran.r-project.org/package=RDS) by Handcock _et al_ which is part of the \"RDS Ananlyst\" suite for analysing respondent-driven sampling data;\n - [rtsdata](https://cran.r-project.org/package=rtsdata) by RTSVizTeam manages time series data dtorage;\n - [threesixtygiving](https://cran.r-project.org/package=threesixtygiving) by Odell accesses download charitable grants from the '360Giving' Platform;\n - [tsbox](https://cran.r-project.org/package=tsbox) by Sax for format-agnostic time series data representation and conversions;\n - [tsibble](https://cran.r-project.org/package=tsibble) by Wang _et al_ for temporal data in an explicit data- and model-oriented format.\n\n### Changes\n\nSee the NEWS.Rd file on [CRAN](https://cran.r-project.org/package=anytime/news.html) or\n[GitHub](https://github.com/eddelbuettel/anytime/blob/master/inst/NEWS.Rd).  In particular, version 0.3.0 corrects\nan overly optimistic heuristic for integer or numeric arguments and now behaves more like R itself. Specifically,\nepoch offsets are interpreted as seconds for datetime objects, and days for date objects.  The prior behaviour can\nbe restored with an option which also be be set globally, see the help page for details.\n\n### Installation\n\nThe package is now on [CRAN](https://cran.r-project.org) and can be installed\nvia a standard\n\n```r\ninstall.packages(\"anytime\")\n```\n\n### Continued Testing\n\nAs we rely on the [tinytest](https://cran.r-project.org/package=tinytest) package, the\nalready-installed package can also be verified via\n\n```r\ntinytest::test_package(\"anytime\")\n```\n\nat any later point.\n\n\n### Contributing\n\nAny problems, bug reports, or features requests for the package can be submitted and\nhandled most conveniently as [Github\nissues](https://github.com/eddelbuettel/anytime/issues) in the repository.\n\nBefore submitting pull requests, it is frequently preferable to first discuss\nneed and scope in such an issue ticket.  See the file\n[Contributing.md](https://github.com/RcppCore/Rcpp/blob/master/Contributing.md) (in the\n[Rcpp](https://github.com/RcppCore/Rcpp) repo) for a brief discussion.\n\n\n### Author\n\nDirk Eddelbuettel\n\n### License\n\nGPL (\u003e= 2)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feddelbuettel%2Fanytime","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feddelbuettel%2Fanytime","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feddelbuettel%2Fanytime/lists"}