generate_dtc: Convert dates and times to SDTM-formatted ISO8601 datetime...

View source: R/date_conversion.R

generate_dtcR Documentation

Convert dates and times to SDTM-formatted ISO8601 datetime values

Description

Convert dates and times to SDTM-formatted ISO8601 datetime values

Usage

generate_dtc(
  datetime = NULL,
  date = NULL,
  time = NULL,
  early_hour = "05",
  assume_24_hr_time = FALSE
)

Arguments

datetime

A combined date/time representation (either an ISO8601-formatted character string or a POSIXt object).

date

The date (either an ISO8601-formatted character string, a Date object, or a POSIXt object).

time

The time (an ISO8601-formatted character string)

early_hour

An hour of the day that would suggest times that are not zero padded are from a 12-hour clock instead of a 24-hour clock. (See Details)

assume_24_hr_time

Assume that times of day are from a 24-hour clock even if the hour is an 'early_hour'. (See Details)

Details

When times are not zero-padded (for example, "5:12" instead of "05:12"), the probability that they are from a 12-hour clock instead of a 24-hour clock is increased. To minimize the impact of this, when the length of any time character string is 4 or 7 characters, times are less than the 'early_hour' will trigger an error under the assumption that generally activities are not happening in the middle of the night. If the times are known to be accurate, setting 'assume_24_hr_time=TRUE' will prevent the error and simply pad the strings with zeros.

If a non-NA value is given for 'datetime', then values in 'date' and 'time' will be ignored.

Value

An SDTM-formatted ISO8601 date-time with "UN:UN:UN" if the time is 'NA'. If all inputs are 'NA', then the output is also 'NA'.

See Also

Other Date management and conversion: dateany_to_date(), is_ISO8601_calendar_datetime(), is_ISO8601_calendar_date(), is_ISO8601_ordinal_datetime(), is_ISO8601_timezone(), is_ISO8601_time(), is_ISO8601_week_datetime(), make_dy(), pattern_ISO8601_any_datetime(), pattern_ISO8601_any_date(), pattern_ISO8601_calendar_datetime(), pattern_ISO8601_calendar_date(), pattern_ISO8601_calendar_year(), pattern_ISO8601_ordinal_datetime(), pattern_ISO8601_ordinal_date(), pattern_ISO8601_timezone(), pattern_ISO8601_time(), pattern_ISO8601_week_datetime(), pattern_ISO8601_week_date(), sdtm_dtc_to_datetime(), sdtm_first_dose(), sdtm_time_actual()


billdenney/Rsdtm documentation built on Dec. 7, 2022, 2:11 a.m.