diff --git a/fastjsonschema/draft04.py b/fastjsonschema/draft04.py
index 6d79a1e..3ee257b 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])\.)*'
diff --git a/fastjsonschema/generator.py b/fastjsonschema/generator.py
index 11358d2..28b9480 100644
--- a/fastjsonschema/generator.py
+++ b/fastjsonschema/generator.py
@@ -93,7 +93,7 @@ class CodeGenerator:
                     '',
                 ]
             )
-        regexs = ['"{}": {}'.format(key, value) for key, value in self._compile_regexps.items()]
+        regexs = ['"{}": re.compile(r"{}")'.format(key, value.pattern) for key, value in self._compile_regexps.items()]
         return '\n'.join(
             [
                 'import re',

ipv6 format leads to cut off string in generated code
Thanks for the quick fix of #21 !

I just tried it, and indeed, the regex pattern is now there. But the code is still broken due to a different issue.

When I generate the code for this 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": {
        "ip": {
            "type": "string",
            "description": "The IP of the future",
            "format": "ipv6"
        }   
    },
    "required": [ "ip" ]
}
```

The resulting code contains the following dict:

```
REGEX_PATTERNS = {
    "ipv6_re_pattern": re.compile('^(?:(?:[0-9A-Fa-f]{1,4}:){6}(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\\\.){3}(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|::(?:[0-9A-Fa-f]{1,4)
}
```

It looks like the line is just cut off at that point, so the code won't work.

`SyntaxError: EOL while scanning string literal`
diff --git a/tests/test_compile_to_code.py b/tests/test_compile_to_code.py
index 394e648..7312f38 100644
--- a/tests/test_compile_to_code.py
+++ b/tests/test_compile_to_code.py
@@ -1,8 +1,19 @@
 import os
 import pytest
+import shutil
 
 from fastjsonschema import JsonSchemaException, compile_to_code
 
+@pytest.yield_fixture(autouse=True)
+def run_around_tests():
+    temp_dir = 'temp'
+    # Code that will run before your test, for example:
+    if not os.path.isdir(temp_dir):
+        os.makedirs(temp_dir)
+    # A test function will be run at this point
+    yield
+    # Code that will run after your test, for example:
+    shutil.rmtree(temp_dir)
 
 def test_compile_to_code():
     code = compile_to_code({
@@ -12,11 +23,9 @@ def test_compile_to_code():
             'c': {'format': 'hostname'},
         }
     })
-    if not os.path.isdir('temp'):
-        os.makedirs('temp')
-    with open('temp/schema.py', 'w') as f:
+    with open('temp/schema_1.py', 'w') as f:
         f.write(code)
-    from temp.schema import validate
+    from temp.schema_1 import validate
     assert validate({
         'a': 'a',
         'b': 1, 
@@ -26,3 +35,18 @@ def test_compile_to_code():
         'b': 1,
         'c': 'example.com',
     }
+
+def test_compile_to_code_ipv6_regex():
+    code = compile_to_code({
+        'properties': {
+            'ip': {'format': 'ipv6'},
+        }
+    })
+    with open('temp/schema_2.py', 'w') as f:
+        f.write(code)
+    from temp.schema_2 import validate
+    assert validate({
+        'ip': '2001:0db8:85a3:0000:0000:8a2e:0370:7334'
+    }) == {
+        'ip': '2001:0db8:85a3:0000:0000:8a2e:0370:7334'
+    }
\ No newline at end of file
diff --git a/tests/test_datetime.py b/tests/test_datetime.py
deleted file mode 100644
index 2263e9f..0000000
--- a/tests/test_datetime.py
+++ /dev/null
@@ -1,15 +0,0 @@
-
-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)

pip install -e .[devel]
parse_log_pytest
requirements.txt
pytest pytest-benchmark pytest-cache
apt-get update apt-get install -y gcc git submodule init git submodule update
3.9
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
astroid==3.3.9
attrs==25.3.0
certifi==2025.1.31
charset-normalizer==3.4.1
colorama==0.4.6
dill==0.3.9
exceptiongroup==1.2.2
execnet==2.1.1
-e git+https://github.com/horejsek/python-fastjsonschema.git@97d45db2d13c3a769d9805cca2a672643b17bb6b#egg=fastjsonschema
idna==3.10
iniconfig==2.1.0
isort==6.0.1
json-spec==0.10.1
jsonschema==4.23.0
jsonschema-specifications==2024.10.1
mccabe==0.7.0
packaging==24.2
platformdirs==4.3.7
pluggy==1.5.0
py-cpuinfo==9.0.0
pylint==3.3.6
pytest==8.3.5
pytest-benchmark==5.1.0
pytest-cache==1.0
referencing==0.36.2
requests==2.32.3
rpds-py==0.24.0
six==1.17.0
tomli==2.2.1
tomlkit==0.13.2
typing_extensions==4.13.0
urllib3==2.3.0
validictory==1.1.3

name: python-fastjsonschema
channels:
  - defaults
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
  - conda-forge
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - ca-certificates=2025.2.25=h06a4308_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.4.4=h6a678d5_1
  - libgcc-ng=11.2.0=h1234567_1
  - libgomp=11.2.0=h1234567_1
  - libstdcxx-ng=11.2.0=h1234567_1
  - ncurses=6.4=h6a678d5_0
  - openssl=3.0.16=h5eee18b_0
  - pip=25.0=py39h06a4308_0
  - python=3.9.21=he870216_1
  - readline=8.2=h5eee18b_0
  - setuptools=75.8.0=py39h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - tzdata=2025a=h04d1e81_0
  - wheel=0.45.1=py39h06a4308_0
  - xz=5.6.4=h5eee18b_1
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - astroid==3.3.9
      - attrs==25.3.0
      - certifi==2025.1.31
      - charset-normalizer==3.4.1
      - colorama==0.4.6
      - dill==0.3.9
      - exceptiongroup==1.2.2
      - execnet==2.1.1
      - idna==3.10
      - iniconfig==2.1.0
      - isort==6.0.1
      - json-spec==0.10.1
      - jsonschema==4.23.0
      - jsonschema-specifications==2024.10.1
      - mccabe==0.7.0
      - packaging==24.2
      - platformdirs==4.3.7
      - pluggy==1.5.0
      - py-cpuinfo==9.0.0
      - pylint==3.3.6
      - pytest==8.3.5
      - pytest-benchmark==5.1.0
      - pytest-cache==1.0
      - referencing==0.36.2
      - requests==2.32.3
      - rpds-py==0.24.0
      - six==1.17.0
      - tomli==2.2.1
      - tomlkit==0.13.2
      - typing-extensions==4.13.0
      - urllib3==2.3.0
      - validictory==1.1.3
prefix: /opt/conda/envs/python-fastjsonschema

tests/test_compile_to_code.py::test_compile_to_code_ipv6_regex
tests/test_compile_to_code.py::test_compile_to_code
fastjsonschema/draft04.py fastjsonschema/generator.py
fastjsonschema/draft04.py fastjsonschema/generator.py