<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/lubridate-1-6-0/"></div></div><div><a data-url="https://www.r-bloggers.com/lubridate-1-6-0/" data-counturl="https://www.r-bloggers.com/lubridate-1-6-0/" data-count="horizontal" data-text="lubridate 1.6.0" class="twitter-share-button" data-via="rbloggers" href="https://twitter.com/share"></a></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="https://blog.rstudio.org/2016/09/15/lubridate-1-6-0/"> RStudio Blog</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<div>
<p>I am pleased to announced lubridate 1.6.0. Lubridate is designed to make working with dates and times as pleasant as possible, and is maintained by <a target="_blank" href="http://vitalie.spinu.info/">Vitalie Spinu</a>. You can install the latest version with:</p>
</div>
<pre><code><span>install.packages</span><span>(</span><span>&quot;lubridate&quot;</span><span>)</span></code></pre>
<p>This release includes a range of bug fixes and minor improvements. Some highlights from this release include:</p>
<ul>
<li><code>period()</code> and <code>duration()</code> constructors now accept character strings and allow a very flexible specification of timespans:
<pre><code><span>period</span><span>(</span><span>&quot;3H 2M 1S&quot;</span><span>)</span>
#> [1] &quot;3H 2M 1S&quot;

<span>duration</span><span>(</span><span>&quot;3 hours, 2 mins, 1 secs&quot;</span><span>)</span>
#> [1] &quot;10921s (~3.03 hours)&quot;

# Missing numerals default to 1. 
# Repeated units are summed
<span>period</span><span>(</span><span>&quot;hour minute minute&quot;</span><span>)</span>
#> [1] &quot;1H 2M 0S&quot;</code></pre>
<p>Period and duration parsing allows for arbitrary abbreviations of time units as long as the specification is unambiguous. For single letter specs, <code>strptime()</code> rules are followed, so <code>m</code> stands for <code>months</code> and <code>M</code> for <code>minutes</code>.</p>
<p>These same rules allows you to compare strings and durations/periods:</p>
<pre><code><span>&quot;2mins 1 sec&quot;</span> <span>></span> <span>period</span><span>(</span><span>&quot;2mins&quot;</span><span>)</span>
#> [1] TRUE</code></pre>
</li>
<li>Date time rounding (with <code>round_date()</code>, <code>floor_date()</code> and <code>ceiling_date()</code>) now supports unit multipliers, like “3 days” or “2 months”:
<pre><code><span>ceiling_date</span><span>(</span><span>ymd_hms</span><span>(</span><span>&quot;2016-09-12 17:10:00&quot;</span><span>)</span>, <span>unit</span> <span>=</span> <span>&quot;5 minutes&quot;</span><span>)</span>
#> [1] &quot;2016-09-12 17:10:00 UTC&quot;</code></pre>
</li>
<li>The behavior of <code>ceiling_date</code> for <code>Date</code> objects is now more intuitive. In short, dates are now interpreted as time intervals that are physically part of longer unit intervals:
<pre><code>|day1| ... |day31|day1| ... |day28| ...
|    January     |   February     | ...</code></pre>
<p>That means that rounding up <code>2000-01-01</code> by a month is done to the boundary between January and February which, i.e. <code>2000-02-01</code>:</p>
<pre><code><span>ceiling_date</span><span>(</span><span>ymd</span><span>(</span><span>&quot;2000-01-01&quot;</span><span>)</span>, <span>unit</span> <span>=</span> <span>&quot;month&quot;</span><span>)</span>
#> [1] &quot;2000-02-01&quot;</code></pre>
<p>This behavior is controlled by the <code>change_on_boundary</code> argument.
<li>It is now possible to compare <code>POSIXct</code> and <code>Date</code> objects:
<pre><code><span>ymd_hms</span><span>(</span><span>&quot;2000-01-01 00:00:01&quot;</span><span>)</span> <span>></span> <span>ymd</span><span>(</span><span>&quot;2000-01-01&quot;</span><span>)</span>
#> [1] TRUE</code></pre>
</li>
<li>C-level parsing now handles English months and AM/PM indicator regardless of your locale. This means that English date-times are now always handled by lubridate C-level parsing and you don’t need to explicitly switch the locale.</li>
<li>New parsing function <code>yq()</code> allows you to parse a year + quarter:
<pre><code><span>yq</span><span>(</span><span>&quot;2016-02&quot;</span><span>)</span>
#> [1] &quot;2016-04-01&quot;</code></pre>
<p>The new <code>q</code> format is available in all lubridate parsing functions.

<p>See the <a target="_blank" href="https://github.com/hadley/lubridate/releases/tag/v1.6.0">release notes</a> for the full list of changes. A big thanks goes to everyone who contributed: @<a target="_blank" href="https://github.com/arneschillert">arneschillert</a>, @<a target="_blank" href="https://github.com/cderv">cderv</a>, @<a target="_blank" href="https://github.com/ijlyttle">ijlyttle</a>, @<a target="_blank" href="https://github.com/jasonelaw">jasonelaw</a>, @<a target="_blank" href="https://github.com/jonboiser">jonboiser</a>, and @<a target="_blank" href="https://github.com/krlmlr">krlmlr</a>.</p>
<p> <a target="_blank" rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/rstudioblog.wordpress.com/3129/"><img alt="" src="http://feeds.wordpress.com/1.0/comments/rstudioblog.wordpress.com/3129/" border="0"></a> <img alt="" src="https://i1.wp.com/pixel.wp.com/b.gif?resize=1%2C1&ssl=1" border="0" data-recalc-dims="1"></p>
<p><div><div><div><div data-width="55" data-show-faces="false" data-send="true" data-layout="box_count" data-height="62" data-href="https://www.r-bloggers.com/lubridate-1-6-0/"></div></div><div><a data-url="https://www.r-bloggers.com/lubridate-1-6-0/" data-counturl="https://www.r-bloggers.com/lubridate-1-6-0/" data-count="vertical" data-text="lubridate 1.6.0" class="twitter-share-button" data-via="rbloggers" href="https://twitter.com/share"></a></div><div></div></div><div></div></div>
<div>
<div>To <strong>leave a comment</strong> for the author, please follow the link and comment on their blog: <strong><a href="https://blog.rstudio.org/2016/09/15/lubridate-1-6-0/"> RStudio Blog</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/?s=tutorial">tutorials</a> on topics such as: <a title="Data science" rel="nofollow" href="https://www.r-bloggers.com/?s=data%20science">Data science</a>, <a title="Big Data" rel="nofollow" href="https://www.r-bloggers.com/?s=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/?s=ggplot2">ggplot2</a>, <a title="Boxplots using lattice and ggplot2 tutorials" rel="nofollow" href="https://www.r-bloggers.com/?s=boxplot">Boxplots</a>, <a title="Maps and gis" rel="nofollow" href="https://www.r-bloggers.com/?s=map">maps</a>, <a title="Animation in R" rel="nofollow" href="https://www.r-bloggers.com/?s=animation">animation</a>), programming (<a title="RStudio IDE for R" rel="nofollow" href="https://www.r-bloggers.com/?s=RStudio">RStudio</a>, <a title="Sweave and literate programming" rel="nofollow" href="https://www.r-bloggers.com/?s=sweave">Sweave</a>, <a title="LaTeX in R" rel="nofollow" href="https://www.r-bloggers.com/?s=LaTeX">LaTeX</a>, <a title="SQL and databases" rel="nofollow" href="https://www.r-bloggers.com/?s=SQL">SQL</a>, <a title="Eclipse IDE for R" rel="nofollow" href="https://www.r-bloggers.com/?s=eclipse">Eclipse</a>, <a title="git and github, Version Control System" rel="nofollow" href="https://www.r-bloggers.com/?s=git">git</a>, <a title="Large data in R using Hadoop" rel="nofollow" href="https://www.r-bloggers.com/?s=hadoop">hadoop</a>, <a title="Web Scraping of google, facebook, yahoo, twitter and more using R" rel="nofollow" href="https://www.r-bloggers.com/?s=Web+Scraping">Web Scraping</a>) statistics (<a title="Regressions and ANOVA analysis tutorials" rel="nofollow" href="https://www.r-bloggers.com/?s=regression">regression</a>, <a title="principal component analysis tutorial" rel="nofollow" href="https://www.r-bloggers.com/?s=PCA">PCA</a>, <a title="Time series" rel="nofollow" href="https://www.r-bloggers.com/?s=time+series">time series</a>, <a title="finance trading" rel="nofollow" href="https://www.r-bloggers.com/?s=trading">trading</a>) and more...
<img height="1" alt="" width="1" src="http://feeds.feedburner.com/~r/RBloggers/~4/iEH0VsW9q60"></a></div></ul>