This gets around the fact that most functions for calculating Julian Day do not support non-integer days.

datetime2doy(datetime, tz = "UTC")

cf2doy(value, unit, tz = "UTC")

Arguments

datetime

POSIXct datetime, or object that can be to POSIXct via as.POSIXct

tz

Time zone of result (default = "UTC")

value

Numeric value of CF date-time

unit

CF style unit (e.g. "days since 2010-01-01")

Value

Numeric Julian date

Author

Alexey Shiklomanov

Examples

datetime2doy("2010-01-01") # 1
#> [1] 1
datetime2doy("2010-01-01 12:00:00") # 1.5
#> [1] 1.5
cf2doy(0, "days since 2007-01-01") 
#> [1] 1
cf2doy(5, "days since 2010-01-01") # 6
#> [1] 6
cf2doy(5, "days since 2010-01-01") # 6
#> [1] 6