<p><div><div><div><div data-width="100" data-show-faces="false" data-send="true" data-layout="button_count" data-height="21" data-href="https://www.r-bloggers.com/anytime-0-2-0-feature-fixes-and-tests/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="http://dirk.eddelbuettel.com/blog/2016/12/24#anytime_0.2.0"> Thinking inside the box </a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<p>A brand new <a target="_blank" rel="nofollow" href="http://dirk.eddelbuettel.com/code/anytime.html">anytime</a> package just arrived at <a target="_blank" rel="nofollow" href="https://cran.r-project.org/">CRAN</a>. 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, <em>no good deed goes unpunished</em>.</p>
<p><a target="_blank" rel="nofollow" href="http://dirk.eddelbuettel.com/code/anytime.html">anytime</a> is a very focused package aiming to do just one thing <em>really</em> well: to convert <em>anything</em> in integer, numeric, character, factor, ordered, … format to either POSIXct or Date objects — and to do so <em>without requiring a format string</em>. See the <a target="_blank" rel="nofollow" href="http://dirk.eddelbuettel.com/code/anytime.html">anytime</a> page, or the <a target="_blank" rel="nofollow" href="https://github.com/eddelbuettel/anytime">GitHub README.md</a> for a few examples.</p>
<p>This releases does a few things:</p>
<ul>
<li>It fixes a misfeature apparent in some timezones: <code>anydate()</code> 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.</li>
<li>New format helpers were added to format datetime or dates objects according to ISO 7601, RFC 2822 or RFC 3339 (see examples below).</li>
<li>Testing is now more stringent with actual comparisons to equivalent base R results; that way we are get getting bitten by different timezones.</li>
</ul>
<p>The following is a quick illustration</p>
<div>
<pre><code>R><span> </span><span>library</span>(anytime)
R><span> </span>p &lt;-<span> </span><span>anytime</span>(<span>&quot;2010-01-02 03:04:05.123456&quot;</span>)
R><span> </span>p
[<span>1</span>] <span>&quot;2010-01-02 03:04:05.123456 CST&quot;</span>
R><span> </span><span>iso8601</span>(p)
[<span>1</span>] <span>&quot;2010-01-02 03:04:05&quot;</span>
R><span> </span><span>rfc2822</span>(p)
[<span>1</span>] <span>&quot;Sat, 02 Jan 2010 03:04:05.123456 -0600&quot;</span>
R><span> </span><span>rfc3339</span>(p)
[<span>1</span>] <span>&quot;2010-01-02T03:04:05.123456-0600&quot;</span>
R><span> </span></code></pre>
</div>
<p>For symmetry, it also works for dates, but is less detailed</p>
<div>
<pre><code>R><span> </span>jl &lt;-<span> </span><span>anydate</span>(<span>&quot;July 04, 1789&quot;</span>)
R><span> </span>jl
[<span>1</span>] <span>&quot;1789-07-04&quot;</span>
R><span> </span><span>iso8601</span>(jl)
[<span>1</span>] <span>&quot;1789-07-04&quot;</span>
R><span> </span><span>rfc2822</span>(jl)
[<span>1</span>] <span>&quot;Sat, 04 Jul 1789&quot;</span>
R><span> </span><span>rfc3339</span>(jl)
[<span>1</span>] <span>&quot;1789-07-04&quot;</span>
R><span> </span></code></pre>
</div>
<p>Of course, all commands are also fully vectorised. See the <a target="_blank" rel="nofollow" href="http://dirk.eddelbuettel.com/code/anytime.html">anytime</a> page, or the <a target="_blank" rel="nofollow" href="https://github.com/eddelbuettel/anytime">GitHub README.md</a> for more examples.</p>
<blockquote>
<h4>Changes in anytime version 0.2.0 (2016-12-24)</h4>
<ul>
<li>
<p>Added (exported) helper functions iso8601(), rfc2822() and rfc3339() to format date(time) objects according to standards</p>
</li>
<li>
<p>Conversion to dates is now more robust thanks to improved internal processing (PR <a target="_blank" rel="nofollow" href="https://github.com/eddelbuettel/anytime/pull/39">#39</a> closing <a target="_blank" rel="nofollow" href="https://github.com/eddelbuettel/anytime/issues/36">#36</a>)</p>
</li>
<li>
<p>The ISO 8601 format is now recognised, however the timezone information is not parsed by Boost Date_Time (which is a known upstream limitation) (PR <a target="_blank" rel="nofollow" href="https://github.com/eddelbuettel/anytime/pull/38">#38</a> closing <a target="_blank" rel="nofollow" href="https://github.com/eddelbuettel/anytime/issues/37">#37</a>)</p>
</li>
<li>
<p>The ‘allFormats.R’ test script was significantly strengthened (<a target="_blank" rel="nofollow" href="https://github.com/eddelbuettel/anytime/pull/40">#40</a>)</p>
</li>
<li>
<p>Test scripts like ‘simpleTests.R’ have as also been strengthened (<a target="_blank" rel="nofollow" href="https://github.com/eddelbuettel/anytime/pull/41">#41</a>); on Windows and in one file two tests need to be skipped.</p>
</li>
<li>
<p>A new ‘bulkTest.R’ test script was added testing parsing against what R returns</p>
</li>
</ul>
</blockquote>
<p>Courtesy of <a target="_blank" rel="nofollow" href="http://dirk.eddelbuettel.com/cranberries/">CRANberries</a>, there is a comparison to <a target="_blank" rel="nofollow" href="http://dirk.eddelbuettel.com/cranberries/2016/12/24#anytime_0.2.0">the previous release</a>. More information is on the <a target="_blank" rel="nofollow" href="http://dirk.eddelbuettel.com/code/anytime.html">anytime</a> page.</p>
<p>For questions or comments use the <a target="_blank" rel="nofollow" href="https://github.com/eddelbuettel/anytime/issues">issue tracker</a> off the <a target="_blank" rel="nofollow" href="https://github.com/eddelbuettel/anytime">GitHub repo</a>.</p>
<p>
This post by <a target="_blank" rel="nofollow" href="http://dirk.eddelbuettel.com/">Dirk Eddelbuettel</a> originated on his <a target="_blank" rel="nofollow" href="http://dirk.eddelbuettel.com/blog/">Thinking inside the box</a> blog. Please report excessive re-aggregation in third-party for-profit settings.</p>
<p>
<p>
<div>
<div>To <strong>leave a comment</strong> for the author, please follow the link and comment on their blog: <strong><a href="http://dirk.eddelbuettel.com/blog/2016/12/24#anytime_0.2.0"> Thinking inside the box </a></strong>.</div>
<hr>
<a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers.com</a> offers <strong><a rel="nofollow" href="https://feedburner.google.com/fb/a/mailverify?uri=RBloggers">daily e-mail updates</a></strong> about <a title="The R Project for Statistical Computing" rel="nofollow" href="https://www.r-project.org/">R</a> news and <a title="R tutorials" rel="nofollow" href="https://www.r-bloggers.com/search/tutorial">tutorials</a> on topics such as: <a title="Data science" rel="nofollow" href="https://www.r-bloggers.com/search/data%20science">Data science</a>, <a title="Big Data" rel="nofollow" href="https://www.r-bloggers.com/search/Big%20Data">Big Data, <a title="R jobs" rel="nofollow" href="https://www.r-users.com/">R jobs</a>, visualization (<a title="ggplot and ggplot2 tutorials" rel="nofollow" href="https://www.r-bloggers.com/search/ggplot2">ggplot2</a>, <a title="Boxplots using lattice and ggplot2 tutorials" rel="nofollow" href="https://www.r-bloggers.com/search/boxplot">Boxplots</a>, <a title="Maps and gis" rel="nofollow" href="https://www.r-bloggers.com/search/map">maps</a>, <a title="Animation in R" rel="nofollow" href="https://www.r-bloggers.com/search/animation">animation</a>), programming (<a title="RStudio IDE for R" rel="nofollow" href="https://www.r-bloggers.com/search/RStudio">RStudio</a>, <a title="Sweave and literate programming" rel="nofollow" href="https://www.r-bloggers.com/search/sweave">Sweave</a>, <a title="LaTeX in R" rel="nofollow" href="https://www.r-bloggers.com/search/LaTeX">LaTeX</a>, <a title="SQL and databases" rel="nofollow" href="https://www.r-bloggers.com/search/SQL">SQL</a>, <a title="Eclipse IDE for R" rel="nofollow" href="https://www.r-bloggers.com/search/eclipse">Eclipse</a>, <a title="git and github, Version Control System" rel="nofollow" href="https://www.r-bloggers.com/search/git">git</a>, <a title="Large data in R using Hadoop" rel="nofollow" href="https://www.r-bloggers.com/search/hadoop">hadoop</a>, <a title="Web Scraping of google, facebook, yahoo, twitter and more using R" rel="nofollow" href="https://www.r-bloggers.com/search/Web+Scraping">Web Scraping</a>) statistics (<a title="Regressions and ANOVA analysis tutorials" rel="nofollow" href="https://www.r-bloggers.com/search/regression">regression</a>, <a title="principal component analysis tutorial" rel="nofollow" href="https://www.r-bloggers.com/search/PCA">PCA</a>, <a title="Time series" rel="nofollow" href="https://www.r-bloggers.com/search/time+series">time series</a>, <a title="finance trading" rel="nofollow" href="https://www.r-bloggers.com/search/trading">trading</a>) and more...
<img height="1" alt="" width="1" src="http://feeds.feedburner.com/~r/RBloggers/~4/6VhIJhAdFVY"></a></div>