commit ce6112399ebf0ff39069a34bc9286242c875555e Author: adam kaminski Date: Fri Feb 9 12:49:34 2024 -0500 pmapi.py : fix for struct_time() and day of year out of range on yyyy-01-01 Fix for `day of year out of range` on 2024-01-01, due to self.tm_yday - 1, which returns `[2024, 1, 1, 2, 3, 0, 0, -1, 0]`. The range for tm_yday should be [1, 366]. # timedatectl set-ntp false # timedatectl set-time "2024-01-01 00:00:00" # /usr/libexec/pcp/bin/pcp-mpstat -P ALL -t 1 -s 2 Traceback (most recent call last): File "/usr/libexec/pcp/bin/pcp-mpstat", line 653, in sts = manager.run() File "/usr/lib64/python3.6/site-packages/pcp/pmcc.py", line 687, in run self._printer.report(self) File "/usr/libexec/pcp/bin/pcp-mpstat", line 606, in report self.print_machine_info(group, manager) File "/usr/libexec/pcp/bin/pcp-mpstat", line 585, in print_machine_info time_string = time.strftime("%x", timestamp.struct_time()) ValueError: day of year out of range diff --git a/src/python/pcp/pmapi.py b/src/python/pcp/pmapi.py index fd8d40e32c..05c8afb079 100644 --- a/src/python/pcp/pmapi.py +++ b/src/python/pcp/pmapi.py @@ -330,7 +330,7 @@ class tm(Structure): pywday = 6 stlist = [self.tm_year + 1900, self.tm_mon + 1, self.tm_mday, self.tm_hour, self.tm_min, self.tm_sec, - pywday, self.tm_yday - 1, self.tm_isdst] + pywday, self.tm_yday + 1, self.tm_isdst] return time.struct_time(stlist) def __str__(self):