@@ -31,7 +31,7 @@ class ValidValues:
3131
3232 nhs_number = "9990548609"
3333
34- for_date_times = [
34+ for_date_times_strict_timezones = [
3535 "2000-01-01" , # Full date only
3636 "2000-01-01T00:00:00+00:00" , # Time and offset all zeroes
3737 "2000-01-01T10:34:27" , # Date with Time only
@@ -44,6 +44,12 @@ class ValidValues:
4444 "1933-12-31T11:11:11.111111+00:00" , # DateTime with milliseconds to 6 decimal places
4545 ]
4646
47+ for_date_times_relaxed_timezones = for_date_times_strict_timezones + [
48+ "2000-01-01T00:00:00+05:00" , # Time and offset all zeroes
49+ "1933-12-31T11:11:11-01:00" , # Negative offset (with hours and minutes not 0)
50+ "1933-12-31T11:11:11.1-05:00" , # DateTime with milliseconds to 1 decimal place
51+ ]
52+
4753 for_strings_with_any_length_chars = (
4854 "This is a really long string with more than 100 characters to test whether the validator is working well!! "
4955 )
@@ -281,7 +287,7 @@ class InvalidValues:
281287 ]
282288
283289 # Strings which are not in acceptable date time format
284- for_date_time_string_formats = [
290+ for_date_time_string_formats_for_relaxed_timezone = [
285291 "" , # Empty string
286292 "invalid" , # Invalid format
287293 "20000101" , # Date digits only (i.e. without hypens)
@@ -290,10 +296,6 @@ class InvalidValues:
290296 "2000" , # Year only
291297 "2000-01" , # Year and month only
292298 "2000-01-01T00:00:00+00" , # Date and time with GMT timezone offset only in hours
293- "2000-01-01T00:00:00-00:00" , # Date and time with negative GMT timezone offset
294- "2000-01-01T00:00:00-01:00" , # Date and time with negative GMT timezone offset
295- "2000-01-01T00:00:00-05:00" , # Date and time with negative offset asides from GMT and BST
296- "2000-01-01T00:00:00+05:00" , # Date and time with offset asides from GMT and BST
297299 "2000-01-01T00:00:00+01" , # Date and time with BST timezone offset only in hours
298300 "12000-01-01T00:00:00+00:00" , # Extra character at start of string
299301 "2000-01-01T00:00:00+00:001" , # Extra character at end of string
@@ -302,7 +304,6 @@ class InvalidValues:
302304 "2000-01-0122:22:22+00:00.000" , # Missing T (with milliseconds)
303305 "2000-01-01T222222+00:00" , # Missing time colons
304306 "2000-01-01T22:22:2200:00" , # Missing timezone indicator
305- "2000-01-01T22:22:22-0100" , # Missing timezone colon
306307 "2000-01-01T22:22:22-01" , # Timezone hours only
307308 "99-01-01T00:00:00+00:00" , # Missing century (i.e. only 2 digits for year)
308309 "01-01-2000T00:00:00+00:00" , # Date in wrong order (DD-MM-YYYY)
@@ -323,6 +324,14 @@ class InvalidValues:
323324 "2000-01-01T00:00:00+00:60" , # Timezone minute 60
324325 ]
325326
327+ for_date_time_string_formats_for_strict_timezone = for_date_time_string_formats_for_relaxed_timezone + [
328+ "2000-01-01T22:22:22-0100" , # Missing timezone colon
329+ "2000-01-01T00:00:00-01:00" , # Date and time with negative GMT timezone offset
330+ "2000-01-01T00:00:00-05:00" , # Date and time with negative offset asides from GMT and BST
331+ "2000-01-01T00:00:00+05:00" , # Date and time with offset asides from GMT and BST
332+ "2000-01-01T00:00:00-00:00" , # Date and time with negative GMT timezone offset
333+ ]
334+
326335 for_lists_of_strings_of_length_1 = [[1 ], [False ], [["Test1" ]]]
327336
328337 for_lists_of_dicts_of_length_1 = [[1 ], [False ], [["Invalid" ]], ["Invalid" ]]
0 commit comments