A brand new anytime package just arrived at CRAN. This is release number eight, evenly spread with over two per month, since the initial release in September. Needless to say I have been told off not to make this many releases. As they say, no good deed goes unpunished.
anytime is a very focused package aiming to do just one thing really well: to convert anything in integer, numeric, character, factor, ordered, … format to either POSIXct or Date objects — and to do so without requiring a format string. See the anytime page, or the GitHub README.md for a few examples.
This releases does a few things:
- It fixes a misfeature apparent in some timezones:
anydate()would somehow wrap around and return the previous day by accident. This has been addressed by moving the conversion to date directly into the C++ side of things.
- New format helpers were added to format datetime or dates objects according to ISO 7601, RFC 2822 or RFC 3339 (see examples below).
- Testing is now more stringent with actual comparisons to equivalent base R results; that way we are get getting bitten by different timezones.
The following is a quick illustration
R> library(anytime) R> p <- anytime("2010-01-02 03:04:05.123456") R> p  "2010-01-02 03:04:05.123456 CST" R> iso8601(p)  "2010-01-02 03:04:05" R> rfc2822(p)  "Sat, 02 Jan 2010 03:04:05.123456 -0600" R> rfc3339(p)  "2010-01-02T03:04:05.123456-0600" R>
For symmetry, it also works for dates, but is less detailed
R> jl <- anydate("July 04, 1789") R> jl  "1789-07-04" R> iso8601(jl)  "1789-07-04" R> rfc2822(jl)  "Sat, 04 Jul 1789" R> rfc3339(jl)  "1789-07-04" R>
Changes in anytime version 0.2.0 (2016-12-24)
Added (exported) helper functions iso8601(), rfc2822() and rfc3339() to format date(time) objects according to standards
The ‘allFormats.R’ test script was significantly strengthened (#40)
Test scripts like ‘simpleTests.R’ have as also been strengthened (#41); on Windows and in one file two tests need to be skipped.
A new ‘bulkTest.R’ test script was added testing parsing against what R returns