@staticmethod<EOL><INDENT>def get_expire_time(cache_duration=None, valid_until=None):<DEDENT>
expire_time = None<EOL>if cache_duration is not None:<EOL><INDENT>expire_time = OneLogin_Saml2_Utils.parse_duration(cache_duration)<EOL><DEDENT>if valid_until is not None:<EOL><INDENT>if isinstance(valid_until, int):<EOL><INDENT>valid_until_time = valid_until<EOL><DEDENT>else:<EOL><INDENT>valid_until_time = OneLogin_Saml2_Utils.parse_SAML_to_time(valid_until)<EOL><DEDENT>if expire_time is None or expire_time > valid_until_time:<EOL><INDENT>expire_time = valid_until_time<EOL><DEDENT><DEDENT>if expire_time is not None:<EOL><INDENT>return '<STR_LIT>' % expire_time<EOL><DEDENT>return None<EOL>
Compares 2 dates and returns the earliest.

:param cache_duration: The duration, as a string.
:type: string

:param valid_until: The valid until date, as a string or as a timestamp
:type: string

:return: The expiration time.
:rtype: int