You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The logic to test if a year is a leap year has been implemented perhaps a dozen times independently within the PEcAn code base, including once as the function is.leap.
2. there are many cases where year %% 4 i== 0 is used although it should be year %% 400 == 0 | (year %% 4 == 0 & year %% 100 != 0) (is.leap and leap_year implement this correctly).
The lubridate package has a function leap_year that returns T/F. We already use this function in many places and I suggest that this is a good solution
(just a comment / food for thought) testing if a year is a leap year is often followed by calculating time steps (e.g. days or seconds/year). lubridate also provides convenience functions for this that would be less error prone than declaring seconds / year or days / month constants repeatedly in the code.
TODO
bugfix: All of the invalid uses of year %% 4 i== 0 should be replaced by a valid function (leap_year)
enhancement: deprecate is.leap and replace it with lubridate::leap_year
documentation add some notes about existing 'helper' functions to the model template README
The text was updated successfully, but these errors were encountered:
The logic to test if a year is a leap year has been implemented perhaps a dozen times independently within the PEcAn code base, including once as the function
is.leap
.2. there are many cases where
year %% 4 i== 0
is used although it should beyear %% 400 == 0 | (year %% 4 == 0 & year %% 100 != 0)
(is.leap
andleap_year
implement this correctly).leap_year
that returns T/F. We already use this function in many places and I suggest that this is a good solutionlubridate
also provides convenience functions for this that would be less error prone than declaring seconds / year or days / month constants repeatedly in the code.TODO
year %% 4 i== 0
should be replaced by a valid function (leap_year
)is.leap
and replace it withlubridate::leap_year
The text was updated successfully, but these errors were encountered: