Skip to contents

new_yearmonth() is a constructor for <grates_yearmonth> objects aimed at developers.

Usage

new_yearmonth(x = integer())

is_yearmonth(xx)

Arguments

x

[integer]

Vector representing the number of months.

double vectors will be converted via as.integer(floor(x)).

xx

R object

Value

A <grates_yearmonth> object.

Details

<grates_yearmonth> objects are stored as the number of months (starting at 0) since the Unix Epoch (1970-01-01). Precision is only to the month level (i.e. the day of the month is always dropped).

References

The algorithm to convert between dates and months relative to the UNIX Epoch comes from the work of Davis Vaughan in the unreleased datea package

Examples

new_yearmonth(1:10)
#> <grates_yearmonth[10]>
#>  [1] "1970-Feb" "1970-Mar" "1970-Apr" "1970-May" "1970-Jun" "1970-Jul"
#>  [7] "1970-Aug" "1970-Sep" "1970-Oct" "1970-Nov"