% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/01_chronon_parse.R
\name{parse_format}
\alias{parse_format}
\title{Candidate format strings for parsing time}
\usage{
parse_format(..., regex = FALSE)
}
\arguments{
\item{...}{Format strings, as for the \code{format} argument of \code{\link[=time_parse]{time_parse()}}.}

\item{regex}{Whether the literal (non-token) text in \code{...} should be
matched as regular expression syntax rather than escaped literally
(e.g. \code{"[/-]"} to accept either \code{/} or \code{-} as a separator). This is a
niche option for irregular text - most formats leave it at the
default, \code{FALSE}. See the \code{regex} argument of \code{\link[=time_parse]{time_parse()}} for
details.}
}
\value{
A character vector of format strings suitable for \code{\link[=time_parse]{time_parse()}},
with a \code{"regex"} attribute for the \code{regex} argument the parser.
}
\description{
Combines one or more format strings into a character vector for use as
the \code{format} argument of \code{\link[=time_parse]{time_parse()}}. When multiple format strings are
given, \code{\link[=time_parse]{time_parse()}} tries each in turn and keeps whichever parses the
most values, so \code{parse_format()} is the usual way to build up a set of
candidates to try (it's also how \code{\link[=chronon_parse_linear]{chronon_parse_linear()}}/
\code{\link[=chronon_parse_cyclical]{chronon_parse_cyclical()}} methods build theirs). It can optionally mark
its candidates as using regex syntax rather than literal text; see the
\code{regex} argument below.
}
\examples{
parse_format("{lin(year)}-{cyc(month, year)}-{cyc(day, month)}")

# Multiple candidates are tried in turn, keeping whichever parses most values
parse_format(
  "{lin(year)}-{cyc(month, year)}-{cyc(day, month)}",
  "{lin(year)}/{cyc(month, year)}/{cyc(day, month)}"
)

# regex = TRUE treats the surrounding text as regular expression syntax
parse_format(
  "{lin(year)}[/-]{cyc(month, year)}[/-]{cyc(day, month)}",
  regex = TRUE
)
}
\seealso{
\code{\link[=time_parse]{time_parse()}} for using the result as \code{format},
\code{\link[=chronon_parse_linear]{chronon_parse_linear()}}/\code{\link[=chronon_parse_cyclical]{chronon_parse_cyclical()}} for calendar-specific
candidates built this way.
}
