Learning Objectives

Parsing Dates

Parsing Dates using {readr}

Parsing dates using {lubridate}

Dates from individual components

Extracting Components

floor_date(ddat, unit = "year")
## [1] "1970-01-01 UTC"
ceiling_date(ddat, unit = "year")
## [1] "1971-01-01 UTC"

Time Spans

Time Zones

Regnal Year Exercise

Consider the regnal.csv, a table of regnal years of English monarchs, taken from Wikipedia: https://en.wikipedia.org/wiki/Regnal_years_of_English_monarchs

“Regnal years” are years that correspond to a monarch, and might differ from the actual reign of that monarch. It’s mostly used for dating legal documents (“nth year of the reign of King X”). It’s a weird English thing. The variables include:

Clean these data to get the start and end dates of each reign in proper date format. E.g.

## # A tibble: 43 × 4
##    monarch    num_years start      end       
##    <chr>      <chr>     <date>     <date>    
##  1 William I  21        1066-10-14 1087-09-09
##  2 William II 13        1087-09-26 1100-08-02
##  3 Henry I    36        1100-08-05 1135-12-01
##  4 Stephen    19        1135-12-26 1154-10-25
##  5 Henry II   35        1154-12-19 1189-07-06
##  6 Richard I  10        1189-09-03 1199-04-06
##  7 John       18        1199-05-27 1216-10-19
##  8 Henry III  57        1216-10-28 1272-11-16
##  9 Edward I   35        1272-11-20 1307-07-07
## 10 Edward II  20        1307-07-08 1327-01-20
## # ℹ 33 more rows

Use the start and end columns to verify that the num_years column from Wikipedia is accurate.