def to_epoch(t_str):
try:<EOL><INDENT>t = float(t_str)<EOL>return t<EOL><DEDENT>except:<EOL><INDENT>for format in constants.TIMESTAMP_STR_FORMATS:<EOL><INDENT>try:<EOL><INDENT>t = datetime.datetime.strptime(t_str, format)<EOL>return float(time.mktime(t.utctimetuple()) * <NUM_LIT> + t.microsecond / <NUM_LIT>)<EOL><DEDENT>except:<EOL><INDENT>pass<EOL><DEDENT><DEDENT><DEDENT>raise exceptions.InvalidDataFormat<EOL>
Covert a timestamp string to an epoch number.
:param str t_str: a timestamp string.
:return int: epoch number of the timestamp.