numbers.py have a bug!!

Issue #779 resolved
eson created an issue
def is_date_format(fmt):
    if fmt is None:
        return False
    fmt = fmt.lower()
    if any([x in fmt for x in DATE_INDICATORS]):
        return not BAD_DATE_RE.search(fmt)
    return False
 if any([x in fmt for x in DATE_INDICATORS]):
        return not BAD_DATE_RE.search(fmt)
that lead to incorrect return

eg: fmt = m"M"d"D";@ (m"月"d"日";@ extract from my excel file)

Comments (9)

  1. CharlieC
    • removed responsible

    Thanks for the report. Unfortunately support for number formats is by definition somewhat limited, not least because some formats are locale specific. The specification even goes so far as to say that but interoperability will only be possible via mutual agreement between implementers.

    To resolve this properly someone would have to implement the microformat as documented in the "implementers notes" part of the documentation. There are currently no plans to do this. As an alternative openpyxl 2.5 will support the datetime cell type which will allow openpyxl to save and read datetimes unambiguously.

  2. CharlieC

    Add heuristics to infer whether it is date, datetime or time (including timedelta / duration) when reading files. Also adjust regex to exclude colours only. Incidentally resolves #779

    → <<cset e81616cb3c3d>>

  3. Log in to comment