1.1 --- a/imiptools/dates.py Mon Aug 31 15:44:46 2015 +0200
1.2 +++ b/imiptools/dates.py Mon Aug 31 18:09:31 2015 +0200
1.3 @@ -476,14 +476,14 @@
1.4 class ValidityError(Exception):
1.5 pass
1.6
1.7 -def check_resolution(dt, resolution):
1.8 +def check_permitted_values(dt, permitted_values):
1.9
1.10 - "Check the datetime 'dt' against the 'resolution' list."
1.11 + "Check the datetime 'dt' against the 'permitted_values' list."
1.12
1.13 if not isinstance(dt, datetime):
1.14 raise ValidityError
1.15
1.16 - hours, minutes, seconds = resolution
1.17 + hours, minutes, seconds = permitted_values
1.18 errors = []
1.19
1.20 if hours and dt.hour not in hours:
1.21 @@ -495,19 +495,19 @@
1.22
1.23 return errors
1.24
1.25 -def correct_datetime(dt, resolution):
1.26 +def correct_datetime(dt, permitted_values):
1.27
1.28 - "Correct 'dt' using the given 'resolution' details."
1.29 + "Correct 'dt' using the given 'permitted_values' details."
1.30
1.31 - carry, hour, minute, second = correct_value((dt.hour, dt.minute, dt.second), resolution)
1.32 + carry, hour, minute, second = correct_value((dt.hour, dt.minute, dt.second), permitted_values)
1.33 return datetime(dt.year, dt.month, dt.day, hour, minute, second, dt.microsecond, dt.tzinfo) + \
1.34 (carry and timedelta(1) or timedelta(0))
1.35
1.36 -def correct_value(value, resolution):
1.37 +def correct_value(value, permitted_values):
1.38
1.39 """
1.40 Correct the given (hour, minute, second) tuple 'value' according to the
1.41 - 'resolution' details.
1.42 + 'permitted_values' details.
1.43 """
1.44
1.45 limits = 23, 59, 59
1.46 @@ -517,7 +517,7 @@
1.47
1.48 # Find invalid values and reset all following values.
1.49
1.50 - for v, values, limit in zip(value, resolution, limits):
1.51 + for v, values, limit in zip(value, permitted_values, limits):
1.52 if reset:
1.53 if values:
1.54 v = values[0]
1.55 @@ -537,7 +537,7 @@
1.56 # significant values if the next valid value is the first in the appropriate
1.57 # series.
1.58
1.59 - for v, values, limit in zip(value, resolution, limits)[::-1]:
1.60 + for v, values, limit in zip(value, permitted_values, limits)[::-1]:
1.61 if carry:
1.62 v += 1
1.63 if v > limit: