diff --git a/README.rst b/README.rst
index 68ff377..e278c60 100644
--- a/README.rst
+++ b/README.rst
@@ -38,12 +38,13 @@ The following extensions are also supported:
 
 * Copying Without Side Effects (`RFC 3894 <https://tools.ietf.org/html/rfc3894>`_)
 * Body (`RFC 5173 <https://tools.ietf.org/html/rfc5173>`_)
-* Date and Index (`RFC 5260 <https://tools.ietf.org/html/rfc5260>`_)
 * Vacation (`RFC 5230 <http://tools.ietf.org/html/rfc5230>`_)
+* Relational (`RFC 5231 <https://tools.ietf.org/html/rfc5231>`_)
 * Imap4flags (`RFC 5232 <https://tools.ietf.org/html/rfc5232>`_)
 
 The following extensions are partially supported:
 
+* Date and Index (`RFC 5260 <https://tools.ietf.org/html/rfc5260>`_)
 * Checking Mailbox Status and Accessing Mailbox Metadata (`RFC 5490 <https://tools.ietf.org/html/rfc5490>`_)
 
 Extending the parser
diff --git a/sievelib/commands.py b/sievelib/commands.py
index 7f6df2e..d26bcb5 100644
--- a/sievelib/commands.py
+++ b/sievelib/commands.py
@@ -98,10 +98,21 @@ address_part = {"name": "address-part",
                 "values": [":localpart", ":domain", ":all"],
                 "type": ["tag"],
                 "required": False}
-match_type = {"name": "match-type",
-              "values": [":is", ":contains", ":matches"],
-              "type": ["tag"],
-              "required": False}
+match_type = {
+    "name": "match-type",
+    "values": [":is", ":contains", ":matches"],
+    "extension_values": {
+        ":count": "relational",
+        ":value": "relational"
+    },
+    "extra_arg": {
+        "type": "string",
+        "values": ['"gt"', '"ge"', '"lt"', '"le"', '"eq"', '"ne"'],
+        "valid_for": [":count", ":value"]
+    },
+    "type": ["tag"],
+    "required": False
+}
 
 
 class Command(object):
@@ -343,9 +354,17 @@ class Command(object):
         :param value: the value to check
         :return: True on succes, False otherwise
         """
-        if "values" not in arg:
+        if "values" not in arg and "extension_values" not in arg:
+            return True
+        if "values" in arg and value.lower() in arg["values"]:
             return True
-        return value.lower() in arg["values"]
+        if "extension_values" in arg:
+            extension = arg["extension_values"].get(value.lower())
+            if extension:
+                if extension not in RequireCommand.loaded_extensions:
+                    raise ExtensionNotLoaded(extension)
+                return True
+        return False
 
     def __is_valid_type(self, typ, typlist):
         """ Check if type is valid based on input type list
@@ -431,7 +450,6 @@ class Command(object):
 
             condition = (
                 atype in curarg["type"] and
-                ("values" not in curarg or avalue in curarg["values"]) and
                 self.__is_valid_value_for_arg(curarg, avalue)
             )
             if condition:
@@ -892,6 +910,59 @@ class HasflagCommand(TestCommand):
             self.rargs_cnt = 1
 
 
+class DateCommand(TestCommand):
+    """date command, part of the date extension.
+
+    https://tools.ietf.org/html/rfc5260#section-4
+    """
+
+    extension = "date"
+    args_definition = [
+        {"name": "zone",
+         "type": ["tag"],
+         "write_tag": True,
+         "values": [":zone", ":originalzone"],
+         "extra_arg": {"type": "string", "valid_for": [":zone"]},
+         "required": False},
+        comparator,
+        match_type,
+        {"name": "header-name",
+         "type": ["string"],
+         "required": True},
+        {"name": "date-part",
+         "type": ["string"],
+         "required": True},
+        {"name": "key-list",
+         "type": ["string", "stringlist"],
+         "required": True}
+    ]
+
+
+class CurrentdateCommand(TestCommand):
+    """currentdate command, part of the date extension.
+
+    http://tools.ietf.org/html/rfc5260#section-5
+    """
+
+    extension = "date"
+    args_definition = [
+        {"name": "zone",
+         "type": ["tag"],
+         "write_tag": True,
+         "values": [":zone"],
+         "extra_arg": {"type": "string"},
+         "required": False},
+        comparator,
+        match_type,
+        {"name": "date-part",
+         "type": ["string"],
+         "required": True},
+        {"name": "key-list",
+         "type": ["string", "stringlist"],
+         "required": True}
+    ]
+
+
 class VacationCommand(ActionCommand):
     args_definition = [
         {"name": "subject",
@@ -937,7 +1008,7 @@ class VacationCommand(ActionCommand):
 
 class SetCommand(ControlCommand):
 
-    """currentdate command, part of the variables extension
+    """set command, part of the variables extension
 
     http://tools.ietf.org/html/rfc5229
     """
@@ -953,37 +1024,6 @@ class SetCommand(ControlCommand):
     ]
 
 
-class CurrentdateCommand(ControlCommand):
-
-    """currentdate command, part of the date extension
-
-    http://tools.ietf.org/html/rfc5260#section-5
-    """
-
-    extension = "date"
-    accept_children = True
-    args_definition = [
-        {"name": "zone",
-         "type": ["tag"],
-         "write_tag": True,
-         "values": [":zone"],
-         "extra_arg": {"type": "string"},
-         "required": False},
-        {"name": "match-value",
-         "type": ["tag"],
-         "required": True},
-        {"name": "comparison",
-         "type": ["string"],
-         "required": True},
-        {"name": "match-against",
-         "type": ["string"],
-         "required": True},
-        {"name": "match-against-field",
-         "type": ["string"],
-         "required": True}
-    ]
-
-
 def add_commands(cmds):
     """
     Adds one or more commands to the module namespace.

diff --git a/sievelib/tests/test_parser.py b/sievelib/tests/test_parser.py
index 65e6393..430cdf1 100644
--- a/sievelib/tests/test_parser.py
+++ b/sievelib/tests/test_parser.py
@@ -779,10 +779,20 @@ if exists ["subject"]
 
 
 class DateCommands(SieveTest):
+
+    def test_date_command(self):
+        self.compilation_ok(b"""require ["date", "relational", "fileinto"];
+if allof(header :is "from" "boss@example.com",
+         date :value "ge" :originalzone "date" "hour" "09",
+         date :value "lt" :originalzone "date" "hour" "17")
+{ fileinto "urgent"; }
+""")
+
     def test_currentdate_command(self):
         self.compilation_ok(b"""require ["date", "relational"];
 
-if allof ( currentdate :value "ge" "date" "2013-10-23" , currentdate :value "le" "date" "2014-10-12" ) 
+if allof(currentdate :value "ge" "date" "2013-10-23",
+         currentdate :value "le" "date" "2014-10-12")
 {
     discard;
 }
@@ -791,7 +801,8 @@ if allof ( currentdate :value "ge" "date" "2013-10-23" , currentdate :value "le"
     def test_currentdate_command_timezone(self):
         self.compilation_ok(b"""require ["date", "relational"];
 
-if allof ( currentdate :zone "+0100" :value "ge" "date" "2013-10-23" , currentdate :value "le" "date" "2014-10-12" ) 
+if allof(currentdate :zone "+0100" :value "ge" "date" "2013-10-23",
+         currentdate :value "le" "date" "2014-10-12")
 {
     discard;
 }
@@ -800,13 +811,22 @@ if allof ( currentdate :zone "+0100" :value "ge" "date" "2013-10-23" , currentda
     def test_currentdate_norel(self):
         self.compilation_ok(b"""require ["date"];
 
-if allof ( 
-  currentdate :zone "+0100" :is "date" "2013-10-23"  
-) 
+if allof (
+  currentdate :zone "+0100" :is "date" "2013-10-23"
+)
 {
     discard;
 }""")
 
+    def test_currentdate_extension_not_loaded(self):
+        self.compilation_ko(b"""require ["date"];
+
+if allof ( currentdate :value "ge" "date" "2013-10-23" , currentdate :value "le" "date" "2014-10-12" )
+{
+    discard;
+}
+""")
+
 
 class VariablesCommands(SieveTest):
     def test_set_command(self):

Better support of relational and date extensions
The current implementation is buggy.
sievelib/tests/test_parser.py::DateCommands::test_currentdate_extension_not_loaded sievelib/tests/test_parser.py::DateCommands::test_date_command
sievelib/tests/test_parser.py::AdditionalCommands::test_add_command sievelib/tests/test_parser.py::AdditionalCommands::test_quota_notification sievelib/tests/test_parser.py::ValidEncodings::test_utf8_file sievelib/tests/test_parser.py::ValidSyntaxes::test_body_extension sievelib/tests/test_parser.py::ValidSyntaxes::test_bracket_comment sievelib/tests/test_parser.py::ValidSyntaxes::test_complex_allof_with_not sievelib/tests/test_parser.py::ValidSyntaxes::test_explicit_comparator sievelib/tests/test_parser.py::ValidSyntaxes::test_fileinto_create sievelib/tests/test_parser.py::ValidSyntaxes::test_hash_comment sievelib/tests/test_parser.py::ValidSyntaxes::test_imap4flags_extension sievelib/tests/test_parser.py::ValidSyntaxes::test_imap4flags_hasflag sievelib/tests/test_parser.py::ValidSyntaxes::test_just_one_command sievelib/tests/test_parser.py::ValidSyntaxes::test_multiline_string sievelib/tests/test_parser.py::ValidSyntaxes::test_multiple_not sievelib/tests/test_parser.py::ValidSyntaxes::test_nested_blocks sievelib/tests/test_parser.py::ValidSyntaxes::test_non_ordered_args sievelib/tests/test_parser.py::ValidSyntaxes::test_reject_extension sievelib/tests/test_parser.py::ValidSyntaxes::test_rfc5228_extended sievelib/tests/test_parser.py::ValidSyntaxes::test_singletest_testlist sievelib/tests/test_parser.py::ValidSyntaxes::test_string_with_bracket_comment sievelib/tests/test_parser.py::ValidSyntaxes::test_true_test sievelib/tests/test_parser.py::ValidSyntaxes::test_truefalse_testlist sievelib/tests/test_parser.py::ValidSyntaxes::test_vacationext_basic sievelib/tests/test_parser.py::ValidSyntaxes::test_vacationext_medium sievelib/tests/test_parser.py::ValidSyntaxes::test_vacationext_with_limit sievelib/tests/test_parser.py::ValidSyntaxes::test_vacationext_with_multiline sievelib/tests/test_parser.py::ValidSyntaxes::test_vacationext_with_single_mail_address sievelib/tests/test_parser.py::InvalidSyntaxes::test_comma_inside_arguments sievelib/tests/test_parser.py::InvalidSyntaxes::test_empty_not sievelib/tests/test_parser.py::InvalidSyntaxes::test_empty_string_list sievelib/tests/test_parser.py::InvalidSyntaxes::test_extra_arg sievelib/tests/test_parser.py::InvalidSyntaxes::test_misplaced_comma_in_string_list sievelib/tests/test_parser.py::InvalidSyntaxes::test_misplaced_comma_in_tests_list sievelib/tests/test_parser.py::InvalidSyntaxes::test_misplaced_parenthesis sievelib/tests/test_parser.py::InvalidSyntaxes::test_missing_semicolon sievelib/tests/test_parser.py::InvalidSyntaxes::test_missing_semicolon_in_block sievelib/tests/test_parser.py::InvalidSyntaxes::test_nested_comments sievelib/tests/test_parser.py::InvalidSyntaxes::test_non_ordered_args sievelib/tests/test_parser.py::InvalidSyntaxes::test_nonclosed_block sievelib/tests/test_parser.py::InvalidSyntaxes::test_nonclosed_tests_list sievelib/tests/test_parser.py::InvalidSyntaxes::test_nonclosed_tests_list2 sievelib/tests/test_parser.py::InvalidSyntaxes::test_nonopened_block sievelib/tests/test_parser.py::InvalidSyntaxes::test_nonopened_tests_list sievelib/tests/test_parser.py::InvalidSyntaxes::test_unclosed_string_list sievelib/tests/test_parser.py::InvalidSyntaxes::test_unknown_token sievelib/tests/test_parser.py::LanguageRestrictions::test_bad_arg_value sievelib/tests/test_parser.py::LanguageRestrictions::test_bad_arg_value2 sievelib/tests/test_parser.py::LanguageRestrictions::test_bad_comparator_value sievelib/tests/test_parser.py::LanguageRestrictions::test_exists_get_string_or_list sievelib/tests/test_parser.py::LanguageRestrictions::test_fileinto_create_without_fileinto sievelib/tests/test_parser.py::LanguageRestrictions::test_fileinto_create_without_mailbox sievelib/tests/test_parser.py::LanguageRestrictions::test_misplaced_elsif sievelib/tests/test_parser.py::LanguageRestrictions::test_misplaced_elsif2 sievelib/tests/test_parser.py::LanguageRestrictions::test_misplaced_nested_elsif sievelib/tests/test_parser.py::LanguageRestrictions::test_not_included_extension sievelib/tests/test_parser.py::LanguageRestrictions::test_test_outside_control sievelib/tests/test_parser.py::LanguageRestrictions::test_unexpected_argument sievelib/tests/test_parser.py::LanguageRestrictions::test_unknown_control sievelib/tests/test_parser.py::DateCommands::test_currentdate_command sievelib/tests/test_parser.py::DateCommands::test_currentdate_command_timezone sievelib/tests/test_parser.py::DateCommands::test_currentdate_norel sievelib/tests/test_parser.py::VariablesCommands::test_set_command sievelib/tests/test_parser.py::CopyWithoutSideEffectsTestCase::test_fileinto_with_copy sievelib/tests/test_parser.py::CopyWithoutSideEffectsTestCase::test_redirect_with_copy