nl: and expires is not an instance of datetime. convert expires to a string, use it as argument for the call to the function typecast_timestamp, substitute the result for expires.
code: expires = typecast_timestamp ( str ( expires ) )