def str_to_datetime(datetimeString, fmt=PENDING): """convert a date/time string into a Python datetime object""" datetimeString = str(datetimeString) specified_fmt = fmt try: if is_archaelogical(): return bcdate_util.str_to_bcdate(datetimeString) if fmt == PENDING: fmt = get_format_of_timeval(datetimeString) if fmt == UTC: return epoch_to_datetime(int(datetimeString)) if fmt == UTC_FLOAT: return epoch_to_datetime(float(datetimeString)) return datetime.strptime(datetimeString, fmt) except Exception, e: raise UnsupportedFormatException(createNiceMessage(datetimeString, specified_fmt, is_archaelogical(), e))
def str_to_datetime(datetimeString, fmt=PENDING): """convert a date/time string into a Python datetime object""" datetimeString = str(datetimeString) specified_fmt = fmt try: if is_archaelogical(): return bcdate_util.str_to_bcdate(datetimeString) if fmt == PENDING: fmt = get_format_of_timeval(datetimeString) if fmt == UTC: return epoch_to_datetime(int(datetimeString)) if fmt == UTC_FLOAT: return epoch_to_datetime(float(datetimeString)) return datetime.strptime(datetimeString, fmt) except Exception, e: raise UnsupportedFormatException( createNiceMessage(datetimeString, specified_fmt, is_archaelogical(), e))
def str_to_datetime(datetimeString, fmt=PENDING): """convert a date/time string into a Python datetime object""" datetimeString = str(datetimeString) if is_archaelogical(): return bcdate_util.str_to_bcdate(datetimeString) try: if fmt == PENDING: fmt = get_format_of_timeval(datetimeString) if fmt == UTC : return epoch_to_datetime(int(datetimeString)) if fmt == UTC_FLOAT: return epoch_to_datetime(float(datetimeString)) return datetime.strptime(datetimeString, fmt) except Exception,e: raise UnsupportedFormatException("Could not find a suitable time format for value {}. Cause {}"\ .format(datetimeString, e ))