Closed yvanrichard closed 10 months ago
I encountered the same/similar issue:
a <- "Pacific/Auckland"
b <- "Europe/Amsterdam"
Sys.time()
#> [1] "2023-06-06 20:24:53 CEST"
library(suncalc)
d <- data.frame(date = as.Date(structure(c(
1234354605, 1234389623, 1234516516.998, 1234525540.999,
1234577723.001
), class = c("POSIXct", "POSIXt"), tzone = "UTC")), lat = 42, lon = -73.9)
d
#> date lat lon
#> 1 2009-02-11 42 -73.9
#> 2 2009-02-11 42 -73.9
#> 3 2009-02-13 42 -73.9
#> 4 2009-02-13 42 -73.9
#> 5 2009-02-14 42 -73.9
withr::with_timezone(a, getSunlightTimes(
data = d,
keep = c("sunrise", "sunset")
))
#> date lat lon sunrise sunset
#> 1 2009-02-10 42 -73.9 2009-02-10 11:59:08 2009-02-10 22:23:17
#> 2 2009-02-10 42 -73.9 2009-02-10 11:59:08 2009-02-10 22:23:17
#> 3 2009-02-12 42 -73.9 2009-02-12 11:56:35 2009-02-12 22:25:52
#> 4 2009-02-12 42 -73.9 2009-02-12 11:56:35 2009-02-12 22:25:52
#> 5 2009-02-13 42 -73.9 2009-02-13 11:55:16 2009-02-13 22:27:09
withr::with_timezone(b, getSunlightTimes(
data = d,
keep = c("sunrise", "sunset")
))
#> date lat lon sunrise sunset
#> 1 2009-02-11 42 -73.9 2009-02-11 11:57:52 2009-02-11 22:24:35
#> 2 2009-02-11 42 -73.9 2009-02-11 11:57:52 2009-02-11 22:24:35
#> 3 2009-02-13 42 -73.9 2009-02-13 11:55:16 2009-02-13 22:27:09
#> 4 2009-02-13 42 -73.9 2009-02-13 11:55:16 2009-02-13 22:27:09
#> 5 2009-02-14 42 -73.9 2009-02-14 11:53:56 2009-02-14 22:28:26
Created on 2023-06-06 with reprex v2.0.2
For reference I use version 0.5.1
I am encountering this same issue - has anyone found any alternatives or ways around this?
Same as #2, fix (I hope) in dev/github version.
getSunlightTimes(date = as.Date('2021-09-26'), lat = -41.28664, lon = 174.77557, keep = c('sunrise', 'sunset'), tz='NZ')
returns
While the output date/times are for the correct day, the returned
date
value is not the date that is passed to the function.