parse_dttm: Parse a date, time, or date-time

View source: R/dtc_parse_dttm.R

parse_dttm_R Documentation

Parse a date, time, or date-time

Description

parse_dttm() extracts date and time components. parse_dttm() wraps around parse_dttm_(), which is not vectorized over fmt.

Usage

parse_dttm_(
  dttm,
  fmt,
  fmt_c = fmt_cmp(),
  na = NULL,
  sec_na = na,
  min_na = na,
  hour_na = na,
  mday_na = na,
  mon_na = na,
  year_na = na
)

parse_dttm(
  dttm,
  fmt,
  fmt_c = fmt_cmp(),
  na = NULL,
  sec_na = na,
  min_na = na,
  hour_na = na,
  mday_na = na,
  mon_na = na,
  year_na = na
)

Arguments

dttm

A character vector of dates, times or date-times.

fmt

In the case of parse_dttm(), a character vector of parsing formats, or a single string format in the case of parse_dttm_(). When a character vector of formats is passed, each format is attempted in turn with the first parsing result to be successful taking precedence in the final result. The formats in fmt can be any strings, however the following characters (or successive repetitions thereof) are reserved in the sense that they are treated in a special way:

  • "y": parsed as year;

  • "m": parsed as month;

  • "d": parsed as day;

  • "H": parsed as hour;

  • "M": parsed as minute;

  • "S": parsed as second.

na, sec_na, min_na, hour_na, mday_na, mon_na, year_na

A character vector of alternative values to allow during matching. This can be used to indicate different forms of missing values to be found during the parsing date-time strings.

Value

A character matrix of six columns: "year", "mon", "mday", "hour", "min" and "sec". Each row corresponds to an element in dttm. Each element of the matrix is the parsed date/time component.


sdtm.oak documentation built on April 3, 2025, 9:37 p.m.