RawCell.is_date() returns false-positive dates for custom formats

Issue #124 resolved
Anonymous created an issue

The method is_date() of the RawCell class in the iter_worksheets module (~line 110) flags a cell format as a date if there is 'm', 'y', 'd', 'h', or 's' in the number_format attribute (and it is a number). This falsely flags certain numbers as dates when they have a format that turns them red for negative values--e.g. the format is 0;[Red]0, since there's a 'd' in it.

This best fix I can think of for this is to add some additional logic to only flag it as a date if it also does not contain any custom formatting code symbols, like "(", "#", or "[". This may miss some specially-formatted dates, but should still catch all the standard date formats. And it's probably best to put the onus on the user to manually convert any specially formatted dates to datetime after reading them in -- i.e., false negatives that are unconverted are probably easier to deal with than false positives (for which you'd either have to recover the number from the converted datetime, or worse, the from_julian function breaks because you fed it a number that didn't correspond to a date.)

Comments (1)

  1. Log in to comment