trim_dates: Trim unknown elements in partial dates
Description
Removes unknown elements from a partial date. For example, "2017-UN-UN"
is trimmed to "2017" and "2017-05-UN" is trimmed to "2017-05".
Values of "UNKN-UN-UN" are converted to NA. Values where only
the year and day are known are converted to just the year, ie "2017-UN-01"
converts to "2017". Full dates are not modified.
Usage
trim_dates(dates, input_sep = "-")
Value
a character vector of trimmed partial dates and full dates
Arguments
dates
a character vector of partial dates in the format "UNKN-UN-UN"
("YYYY-MM-DD"); full dates can also be included
input_sep
the character that separates date components in the input
vector dates, default is "-"