#NEWLINE# @ classmethod #NEWLINE# def utcfromtimestamp( cls , timestamp , allow_future = False ) : #NEWLINE# #INDENT# 'Converts a str or int epoch time to datetime.\n\n    Note: this method drops ms from timestamps.\n\n    Args:\n      timestamp: str, int, or float epoch timestamp.\n      allow_future: boolean, default False, True to allow future timestamps.\n    Returns:\n      datetime representation of the timestamp.\n    Raises:\n      ValueError: timestamp is invalid.\n      EpochValueError: the timestamp is valid, but unacceptable.\n      EpochFutureValueError: timestamp under an hour in future.\n      EpochExtremeFutureValueError: timestamp over an hour in future.\n    ' #NEWLINE# try : #NEWLINE# #INDENT# timestamp = int ( float ( timestamp ) ) #NEWLINE# dt = datetime . datetime . utcfromtimestamp ( timestamp ) #NEWLINE# #UNINDENT# except ( TypeError , ValueError ) : #NEWLINE# #INDENT# raise ValueError ( ( 'timestamp is None, empty, or otherwise invalid: %s' % timestamp ) ) #NEWLINE# #UNINDENT# now = datetime . datetime . utcnow ( ) #NEWLINE# if ( ( not allow_future ) and ( dt > now ) ) : #NEWLINE# #INDENT# msg = ( 'datetime in the future: %s' % dt ) #NEWLINE# if ( dt > ( now + datetime . timedelta ( minutes = 66 ) ) ) : #NEWLINE# #INDENT# raise EpochExtremeFutureValueError ( msg ) #NEWLINE# #UNINDENT# raise EpochFutureValueError ( msg ) #NEWLINE# #UNINDENT# return dt