R/time.R

Defines functions .dateFromDoy .doyFromDate .yearFromDate

.yearFromDate <- function(date) {
	date <- as.character(date)
	as.numeric(format(as.Date(date), "%Y"))
}

.doyFromDate <- function(date) {
	date <- as.character(date)
	as.numeric(format(as.Date(date), "%j"))
}

.dateFromDoy <- function(doy, year) {
	year <- round(year)
	doy <- round(doy)
	return(as.Date(doy, origin=paste(year-1, "-12-31", sep='')))
}
rspatial/luna documentation built on Feb. 3, 2024, 4:40 a.m.