Skip to content

Commit

Permalink
Merge pull request #4726 from jedwards4b/leapyr_correction2
Browse files Browse the repository at this point in the history
corrected leap year correction logic
  • Loading branch information
jedwards4b authored Dec 30, 2024
2 parents 85922c0 + 6f14964 commit ac8e583
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion CIME/SystemTests/system_tests_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,8 @@ def _leap_year_correction(startdatetime, restdatetime):
"""
Compute correction needed for restdate time if model is using NO_LEAP calendar
>>> SystemTestsCommon._leap_year_correction(datetime.strptime("00031231","%Y%m%d"), datetime.strptime("00040101","%Y%m%d"))
datetime.timedelta(0)
>>> SystemTestsCommon._leap_year_correction(datetime.strptime("20000225","%Y%m%d"), datetime.strptime("20000301","%Y%m%d"))
datetime.timedelta(days=1)
>>> SystemTestsCommon._leap_year_correction(datetime.strptime("20010225","%Y%m%d"), datetime.strptime("20010301","%Y%m%d"))
Expand All @@ -266,7 +268,7 @@ def _leap_year_correction(startdatetime, restdatetime):
if calendar.isleap(ryr):
dayscorrected += 1
ryr = ryr + 1
if rmon > 2 and smon <= 2 or restdatetime.year > syr:
if rmon > 2 and (smon <= 2 or restdatetime.year > syr):
if calendar.isleap(ryr):
dayscorrected += 1
logger.info("correcting calendar for no leap {}".format(dayscorrected))
Expand Down

0 comments on commit ac8e583

Please sign in to comment.