# HG changeset patch # User Paul Boddie # Date 1439672211 -7200 # Node ID 0549289186cde22e9ea191ceeb3776857e7da6a4 # Parent 7e307171a752ac856c9ffdf50862fc81e93aa5b0 Accumulate and return errors found for invalid datetimes. diff -r 7e307171a752 -r 0549289186cd imiptools/client.py --- a/imiptools/client.py Fri Aug 14 00:44:53 2015 +0200 +++ b/imiptools/client.py Sat Aug 15 22:56:51 2015 +0200 @@ -429,10 +429,10 @@ for period in self.obj.get_periods(tzid): start = period.get_start() end = period.get_end() - start_result = self.check_resolution(start, resolution) - end_result = self.check_resolution(end, resolution) - if start_result or end_result: - invalid.append((period.origin, start_result, end_result)) + start_errors = self.check_resolution(start, resolution) + end_errors = self.check_resolution(end, resolution) + if start_errors or end_errors: + invalid.append((period.origin, start_errors, end_errors)) return invalid @@ -444,15 +444,16 @@ raise ValidityError hours, minutes, seconds = resolution + errors = [] if hours and dt.hour not in hours: - return "hour" + errors.append("hour") if minutes and dt.minute not in minutes: - return "minute" + errors.append("minute") if seconds and dt.second not in seconds: - return "second" + errors.append("second") - return None + return errors # Object retrieval.