% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/utils.R
\name{bde_parse_dates}
\alias{bde_parse_dates}
\title{Parse dates}
\usage{
bde_parse_dates(dates_to_parse)
}
\arguments{
\item{dates_to_parse}{Dates to parse}
}
\value{
A \code{\link[=as.Date]{Date}} object.
}
\description{
This function is tailored for date formats used in this package and may fail
with other datasets. See \strong{Examples} for formats that are supported.
\subsection{Date Formats}{\tabular{lll}{
   \strong{FREQUENCY} \tab \strong{FORMAT} \tab \strong{EXAMPLES} \cr
   \strong{Daily / Business day} \tab DD MMMMYYYY \tab \emph{02 FEB2019} \cr
   \strong{Monthly} \tab MMM YYYY \tab \emph{MAR 2020} \cr
   \strong{Quarterly} \tab MMM YYYY, where MMM is the first or the last month of the quarter, depending on the value of its variable OBSERVED. \tab For the first quarter of 2020: \emph{ENE 2020, MAR 2020} \cr
   \strong{Half-yearly} \tab MMM YYYY, where MMM is the first or the last month of the halfyear period, depending on the value of its variable OBSERVED. \tab For the first half of 2020: \emph{ENE 2020, JUN 2020} \cr
   \strong{Annual} \tab YYYY \tab \emph{2020} \cr
}

}
}
\details{
Tries to parse strings representing dates using \code{\link[=as.Date]{as.Date()}}
}
\examples{
# Formats parsed
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)

#-----------------------------------

# Formats not admitted
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)
}
\seealso{
\code{\link[=as.Date]{as.Date()}}
}
\concept{utils}
