View source: R/01_chronon_parse.R
| parse_format | R Documentation |
Combines one or more format strings into a character vector for use as
the format argument of time_parse(). When multiple format strings are
given, time_parse() tries each in turn and keeps whichever parses the
most values, so parse_format() is the usual way to build up a set of
candidates to try (it's also how chronon_parse_linear()/
chronon_parse_cyclical() methods build theirs). It can optionally mark
its candidates as using regex syntax rather than literal text; see the
regex argument below.
parse_format(..., regex = FALSE)
... |
Format strings, as for the |
regex |
Whether the literal (non-token) text in |
A character vector of format strings suitable for time_parse(),
with a "regex" attribute for the regex argument the parser.
time_parse() for using the result as format,
chronon_parse_linear()/chronon_parse_cyclical() for calendar-specific
candidates built this way.
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
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.