def dt_to_ts(value):
if not isinstance(value, datetime):<EOL><INDENT>return value<EOL><DEDENT>return calendar.timegm(value.utctimetuple()) + value.microsecond / <NUM_LIT><EOL>
If value is a datetime, convert to timestamp