def parse_date_universal(datestring): formats = [ '%d.%m.%Y', # german '%Y-%m-%d', # ISO '%Y%m%d', # ISO, compact '%Y', # Year only ] for format in formats: logger.debug("Trying to parse date '{}' with format '{}'".format( datestring, format)) try: parsed = Arrow.strptime(datestring, format) logger.debug( "Successfully parsed date '{}' with format '{}': {}".format( datestring, format, parsed)) return parsed except: pass
def from_german(date): return Arrow.strptime(date, '%d.%m.%Y')