is_date_format still gives wrong false positives
Created originally on Bitbucket by kound (Carli)
As described in #124 (closed) is_date_format gives false positives. My custom format is: "Y: "0.00"m";"Y: "-0.00"m";"Y: m";@ where m stands for meters (SI-Unit).
As the given number 5334664.86 is to large, it will fail to load the sheet.
So better to remove constants first:
#!python
DATE_INDICATORS = 'dmyhs'
COLORS = "(\[BLACK|BLUE|CYAN|GREEN|MAGENTA|RED|WHITE|YELLOW\])"
BAD_DATE_RE = re.compile(r'(\[{0}\])|((?<=)#).*[dmhys]+.*#?'.format(COLORS), re.IGNORECASE + re.UNICODE)
IGNORE_CONSTANTS = re.compile(r'"[^"]*"',re.UNICODE)
def is_date_format(fmt):
if fmt is None:
return False
fmt = fmt.lower()
fmt = IGNORE_CONSTANTS.sub("",fmt)
if any([x in fmt for x in DATE_INDICATORS]):
return not BAD_DATE_RE.search(fmt)
return False
(Sorry that I don't do a pull request - I am behind a restrictive firewall and can't user hg or git)
Attachments: minimal_defined_format.xlsx