def toDatetime(value, format=None):
if value and value is not None:<EOL><INDENT>if format:<EOL><INDENT>value = datetime.strptime(value, format)<EOL><DEDENT>else:<EOL><INDENT>if int(value) == <NUM_LIT:0>:<EOL><INDENT>value = <NUM_LIT><EOL><DEDENT>value = datetime.fromtimestamp(int(value))<EOL><DEDENT><DEDENT>return value<EOL>
Returns a datetime object from the specified value.

        Parameters:
            value (str): value to return as a datetime
            format (str): Format to pass strftime (optional; if value is a str).