nebius/SWE-bench-extra huggingface dataset:
Repository: horejsek/python-fastjsonschema

Issue:
"date-time" not full supported
e.g.:

```python
>>> import fastjsonschema
>>> fastjsonschema.validate({'type': 'string', 'format': 'date-time'},'2020-09-09T01:01:01+0100')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/jens/repos/python-fastjsonschema/fastjsonschema/__init__.py", line 113, in validate
    return compile(definition, handlers, formats, use_default)(data)
  File "<string>", line 8, in validate
fastjsonschema.exceptions.JsonSchemaValueException: data must be date-time
```
Support was added with: https://github.com/horejsek/python-fastjsonschema/pull/7/
But a later refactor seems to remove this.
And there is no test for it: https://github.com/horejsek/python-fastjsonschema/blob/32476cfd4d97f92cae52d686eb471361503bf4ba/tests/test_format.py#L9-L19

Comments:

Patch:
diff --git a/fastjsonschema/draft04.py b/fastjsonschema/draft04.py
index a5b132b..394f263 100644
--- a/fastjsonschema/draft04.py
+++ b/fastjsonschema/draft04.py
@@ -26,7 +26,7 @@ class CodeGeneratorDraft04(CodeGenerator):
     # vs. 9 ms with a regex! Other modules are also ineffective or not available in standard
     # library. Some regexps are not 100% precise but good enough, fast and without dependencies.
     FORMAT_REGEXS = {
-        'date-time': r'^\d{4}-[01]\d-[0-3]\d(t|T)[0-2]\d:[0-5]\d:[0-5]\d(?:\.\d+)?(?:[+-][0-2]\d:[0-5]\d|z|Z)\Z',
+        'date-time': r'^\d{4}-[01]\d-[0-3]\d(t|T)[0-2]\d:[0-5]\d:[0-5]\d(?:\.\d+)?(?:[+-][0-2]\d:[0-5]\d|[+-][0-2]\d[0-5]\d|z|Z)\Z',
         'email': r'^[^@]+@[^@]+\.[^@]+\Z',
         'hostname': r'^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]{0,61}[A-Za-z0-9])\Z',
         'ipv4': r'^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\Z',


Test patch:
diff --git a/tests/test_format.py b/tests/test_format.py
index f742344..c43abc5 100644
--- a/tests/test_format.py
+++ b/tests/test_format.py
@@ -14,6 +14,7 @@ exc = JsonSchemaValueException('data must be date-time', value='{data}', name='d
     ('2018-02-05T14:17:10.00Z\n', exc),
     ('2018-02-05T14:17:10.00Z', '2018-02-05T14:17:10.00Z'),
     ('2018-02-05T14:17:10Z', '2018-02-05T14:17:10Z'),
+    ('2020-09-09T01:01:01+0100', '2020-09-09T01:01:01+0100'),
 ])
 def test_datetime(asserter, value, expected):
     asserter({'type': 'string', 'format': 'date-time'}, value, expected)
Repository: horejsek/python-fastjsonschema

Issue:
JsonSchemaException when using date-time with RFC 3339 compliant string
Validation fails with this example:

```
import json

import fastjsonschema

schema = {
    "$schema": "http://json-schema.org/draft-07/schema#",
    "$id": "https://example.com/example.schema.json",
    "title": "Example",
    "description": "An example schema",
    "type": "object",
    "properties": {
        "date": {
            "type": "string",
            "description": "Some date",
            "format": "date-time"
        }   
    }
}

validate = fastjsonschema.compile(schema)

validate({"date": "2018-02-05T14:17:10Z"})
```

The output is:

```
Traceback (most recent call last):
  File "validate_simple_example.py", line 22, in <module>
    validate({"date": "2018-02-05T14:17:10Z"})
  File "<string>", line 16, in validate_https___example_com_example_schema_json
fastjsonschema.exceptions.JsonSchemaException
```

According to the [json schema docs](http://json-schema.org/latest/json-schema-validation.html#rfc.section.7.3.1) all RFC 3339 timestamps should be valid.

I think the problem is the milliseconds part. It should be optional if I'm not wrong.

The above example runs fine with: `validate({"date": "2018-02-05T14:17:10.00Z"})`

The current regex is:

```
^\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d\.\d+(?:[+-][0-2]\d:[0-5]\d|Z)?$
```

I suggest changing it to:

```
^\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d(?:\.\d+)?(?:[+-][0-2]\d:[0-5]\d|Z)?$
```

Also maybe it's worth thinking about not using regexes for format validation for some of the stuff (like ips, dates, etc.)

Comments:

Patch:
diff --git a/fastjsonschema/draft04.py b/fastjsonschema/draft04.py
index 3ee257b..6d79a1e 100644
--- a/fastjsonschema/draft04.py
+++ b/fastjsonschema/draft04.py
@@ -18,7 +18,7 @@ JSON_TYPE_TO_PYTHON_TYPE = {
 class CodeGeneratorDraft04(CodeGenerator):
     # pylint: disable=line-too-long
     FORMAT_REGEXS = {
-        'date-time': r'^\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d\.\d+(?:[+-][0-2]\d:[0-5]\d|Z)?$',
+        'date-time': r'^\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d(?:\.\d+)?(?:[+-][0-2]\d:[0-5]\d|Z)?$',
         'email': r'^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+$',
         'hostname': (
             r'^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*'


Test patch:
diff --git a/tests/test_datetime.py b/tests/test_datetime.py
new file mode 100644
index 0000000..2263e9f
--- /dev/null
+++ b/tests/test_datetime.py
@@ -0,0 +1,15 @@
+
+import pytest
+
+from fastjsonschema import JsonSchemaException
+
+
+exc = JsonSchemaException('data must be date-time')
+@pytest.mark.parametrize('value, expected', [
+    ('', exc),
+    ('bla', exc),
+    ('2018-02-05T14:17:10.00Z', '2018-02-05T14:17:10.00Z'),
+    ('2018-02-05T14:17:10Z', '2018-02-05T14:17:10Z'),
+])
+def test_datetime(asserter, value, expected):
+    asserter({'type': 'string', 'format': 'date-time'}, value, expected)