From 6f1496498f3ba66f036d09b5acac78a92270a68b Mon Sep 17 00:00:00 2001 From: Jim Edwards Date: Mon, 30 Dec 2024 08:27:52 -0700 Subject: [PATCH] corrected leap year correction logic --- CIME/SystemTests/system_tests_common.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CIME/SystemTests/system_tests_common.py b/CIME/SystemTests/system_tests_common.py index 320bc08b283..02e74910854 100644 --- a/CIME/SystemTests/system_tests_common.py +++ b/CIME/SystemTests/system_tests_common.py @@ -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")) @@ -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))