Closed putmanlab closed 2 years ago
Many thanks for this report! I will investigate as soon as possible what has changed in 'lubridate', and if the bug is in 'photobiology' or 'lubridate'. I suspect the problem may be caused by a work-around I have in 'photobiology' for a situation where the tz was not set correcly by 'lubridate'.
I suspect the problem has to do with the change in 'lubridate' from "UTC"
as default time zone to ""
as default time zone in functions like "now()"
and conversion functions like "ymd()"
.
This guess was wrong. The problem stems at least in part from the use of lubridate::today()
as default for date in sunrise_time()
, sunset_time()
and noon_time()
in 'photobiology' as today() returns a Date
instead of a POSIXct
and thus lacks a time zone setting. Another problem is that lubridate::floor_date()
converts POSIXct
objects to Date
, thus dropping the time zone information. I have started the revision to the code but it is not yet working when the argument passed to date
has length > 1.
Added unit tests and tested with 'lubridate' 1.7.8, 1.7.9.2 and 1.8.0. Tested with 'tibble' 3.1.0 and 3.1.7. All under R 4.2.1. The previously buggy functions now return the correct values in all cases, independently of input being a Date
or POSIXct
object. For Date
arguments passed to date
the default is tz = "UTC"
. The default for date
is now lubridate function now()
instead of today()
, now called with tz = "UTC"
. Currently tz
is used to determine to which data an instant in time belongs.
It is fixed for me. Thanks for the rapid response, and many thanks for developing a very useful package!
You are welcome! Once again thanks for reporting the problem!
It seems
sunrise_time
is not correct for non-UTC times with recent versions of lubridate or R, as shown in the User Guide.However, regressing to earlier versions of lubridate and R but using the same photobiology version results in the correct time.