as_years_datey: Convert a 'datey' to calendar years (including fractional...

as_years_dateyR Documentation

Convert a datey to calendar years (including fractional part)

Description

Converts a datey to calendar years, including a fractional part that represents the proportion of the calendar year that has elapsed.

For example, the middle of 2000-10-01 is precisely three-quarters through the (leap) year 2000 and so as.double(mid_day(2000,10,1)) results in 2000.75.

as.numeric() is the same as as.double().

as.integer() gives the calendar year as an integer, e.g. as.integer(datey(2000.75)) is 2000. It is also the case that if x is a datey then as.integer(x) is the same as as.integer(as.double(x)).

Usage

## S3 method for class 'datey'
as.double(x, ...)

## S3 method for class 'datey'
as.integer(x, ...)

Arguments

x

The datey to convert to years.

...

Not used.

Value

A vector of double.

See Also

datey, as_years_durationy, ops

Examples

t <- datey(2000.75)
t                   # 2000-10-01.5
as.double(t)        # 2000.75
as.numeric(t)       # 2000.75
as.integer(t)       # 2000
identical(as.integer(t), 2000L) # TRUE

datey documentation built on July 14, 2026, 5:06 p.m.