Reflow potentially invalid time components to adjacent fields
Source:R/reflow_fields.R
reflow_fields.Rd
Reflow potentially invalid time components to adjacent fields
Arguments
- fmat
a fields matrix as part of a partial_time or partial_difftime
- days
a logical indicating whether year and month should be consolidated into total days. If an integer is provided, days should represent the "leap-time" to add on top of non-leap conversion.
Examples
# example with difftimes (when you only care about days of change)
x <- as.parttime("2019-06-23 04:33:21.123")
y <- as.parttime("2018-02-08 12:59:28.987")
diff_fields <- vctrs::field(x, "pttm_mat") - vctrs::field(y, "pttm_mat")
parttime:::reflow_fields(diff_fields)
#> year month day hour min sec tzhour
#> 2019-06-23 04:33:21.123 1 4 14 15 33 52.136 0
# if we want to assume 0.25 leap days per year
parttime:::reflow_fields(diff_fields, days = TRUE)
#> year month day hour min sec tzhour
#> 2019-06-23 04:33:21.123 NA NA 469 21 33 52.136 0
# if we want to assert that there were no leap days
parttime:::reflow_fields(diff_fields, days = 0)
#> year month day hour min sec tzhour
#> 2019-06-23 04:33:21.123 NA NA 469 15 33 52.136 0