bde_parse_dates: Parse dates from strings

View source: R/utils.R

bde_parse_datesR Documentation

Parse dates from strings

Description

Parse strings representing dates with as.Date(). This function is tailored to date formats used in this package and may not parse other datasets. See Examples for supported formats.

Usage

bde_parse_dates(dates_to_parse)

Arguments

dates_to_parse

A character vector of date strings to parse.

Details

Date formats

FREQUENCY FORMAT EXAMPLES
Daily / Business day ⁠DD MMMMYYYY⁠ ⁠02 FEB2019⁠
Monthly ⁠MMM YYYY⁠ ⁠MAR 2020⁠
Quarterly ⁠MMM YYYY⁠, where MMM is the first or last month of the quarter, depending on the value of the OBSERVED variable. For the first quarter of 2020: ⁠ENE 2020⁠, ⁠MAR 2020⁠
Half-yearly ⁠MMM YYYY⁠, where MMM is the first or last month of the half-year period, depending on the value of its OBSERVED variable. For the first half of 2020: ⁠ENE 2020⁠, ⁠JUN 2020⁠
Annual YYYY 2020

See vignette("csv_manual", package = "tidyBdE") for details.

Value

A vector of Date values.

See Also

  • bde_catalog_load() and bde_series_load() use this parser.

  • as.Date() provides base R date conversion.

Examples

# Supported formats.
would_parse <- c(
  "02 FEB2019", "15 ABR 1890", "MAR 2020", "ENE2020",
  "2020", "12-1993", "01-02-2014", "01/02/1990"
)

parsed_ok <- bde_parse_dates(would_parse)

class(parsed_ok)

tibble::tibble(raw = would_parse, parsed = parsed_ok)

# Unsupported formats.

wont_parse <- c("JAN2001", "2010-01-12", "01 APR 2017", "01/31/1990")

parsed_fail <- bde_parse_dates(wont_parse)

class(parsed_fail)

tibble::tibble(raw = wont_parse, parsed = parsed_fail)

tidyBdE documentation built on July 7, 2026, 1:06 a.m.