
Create or decompose a datey using calendar year, month, day and day fraction
Source: R/datey.R
ymdf.RdThe lengths of vector arguments must be multiples of each other.
to_ymdf() returns a list of the year, month, day and day_fraction
breakdown of a datey, where
yearis anintegerin [1000,3000],monthis anintegerin [1,12],dayis anintegerin [1,N], where N is the number of days in the month specified byyearandmonth, andday_fractionis adoublein [0,1) representing the fraction of the day, where e.g. 0 means the start and 0.5 means the middle of the day.
Alternatively, if you want only one or two components, use the list-like
syntax $year, $month, $day or $day_fraction.
If the datey was constructed using end_day or day_fraction = 1 then
to_ymdf() will return the start of the next day with day_fraction = 0.
from_ymdf() creates a datey from a calendar year, month, and day
fraction. In practice, prefer one of start_day(), mid_day() or
end_day() for clarity.
Arguments
- datey
A
dateyto be deconstructed.- year
Calendar year. Valid years are from 1000 to 3000 (although the only legal date in 3000 is the start of 3000-01-01). If provided as
doublethen these must be integers.- month
Month number in calendar year, with 1 representing January. If provided as
doublethen these must be integers.- day
Day number in month, with 1 representing the first day of the month. If provided as
doublethen these must be integers.- day_fraction
The fraction of the day, in [0,1]. 0 means the start of the day, 0.5 means the middle of the day, and 1 means the end of the day (which is identical to the start of the next day).
- strict
How to handle invalid arguments. If
strictisTRUE– the default – then execution is stopped. IfstrictisFALSEthenNAis returned.NA arguments result in NA (and do not stop execution) regardless of
strict.
Value
from_ymdf returns a vector of datey.
to_ymdf returns a list of
integer vector year,
integer vector month,
integer vector day, and
double vector day_fraction.
See also
Use datey() to create a datey direct from years or a base R date.
Use the syntax $year, $month, $day or $day_fraction
to extract one component at a time.