Closed danielvartan closed 2 years ago
Found the error. It's not suncalc
fault, the error message is coming from the lubridate
package:
lubridate::force_tz(
time = lubridate::ymd_hms("2020-01-01 01:00:00 UTC"),
tzone = "America/New_York"
)
#> Error: CCTZ: Unrecognized output timezone: "America/New_York"
suncalc::getSunlightTimes
code:
function (date = NULL, lat = NULL, lon = NULL, data = NULL,
keep = c("solarNoon", "nadir", "sunrise", "sunset", "sunriseEnd",
"sunsetStart", "dawn", "dusk", "nauticalDawn", "nauticalDusk",
"nightEnd", "night", "goldenHourEnd", "goldenHour"),
tz = "UTC")
{
data <- .buildData(date = date, lat = lat, lon = lon, data = data)
if (!"Date" %in% class(data$date)) {
stop("date must to be a Date object (class Date)")
}
available_var <- c("solarNoon", "nadir", "sunrise", "sunset",
"sunriseEnd", "sunsetStart", "dawn", "dusk", "nauticalDawn",
"nauticalDusk", "nightEnd", "night", "goldenHourEnd",
"goldenHour")
stopifnot(all(keep %in% available_var))
data <- data %>% .[, `:=`(date, lubridate::force_tz(lubridate::as_datetime(date) +
lubridate::hours(12), Sys.timezone()))] %>% .[, `:=`((available_var),
.getTimes(date = date, lat = lat, lng = lon))] %>% .[,
c("date", "lat", "lon", keep), with = FALSE] %>% .[,
`:=`(date, as.Date(date))] %>% as.data.frame()
invisible(lapply(setdiff(colnames(data), c("date", "lat",
"lon")), function(x) attr(data[[x]], "tzone") <<- tz))
return(data)
}
Everything is working as it should today... I installed R 4.2.0 yesterday, maybe it need a system restart to work properly.
See this issue to learn more.
Hi,
I'm trying to run the package, but I keep getting the following error message.
Session info
Created on 2022-05-09 by the reprex package (v2.0.1)
Created on 2022-05-09 by the reprex package (v2.0.1)