[Libreoffice-bugs] [Bug 144359] LibreOffice allows entry of wrong dates for format

bugzilla-daemon at bugs.documentfoundation.org bugzilla-daemon at bugs.documentfoundation.org
Thu Sep 9 16:29:02 UTC 2021


https://bugs.documentfoundation.org/show_bug.cgi?id=144359

--- Comment #7 from Mike Kaganski <mikekaganski at hotmail.com> ---
(In reply to Edward Redondo from comment #6)
> My typo "9/081/2021" typo in a date-formatted cell would have the "081" in
> red telling me that is a wrong entry for the date format. Is that doable?

No.

1. Format string does not limit the ways that you may *enter* the valid date.
E.g., defining a date format like MM/DD/YY, you may enter "aug 1" (in a cell
with en-US number format), and get it converted to a date; or you may enter
"2021-09-09", and also get it converted. Or you may enter 10%, and the entry
will get recognized. Or 1 2/3. And so on. All these will get recognized as a
valid *number* (using different rules built into the program string parser),
and will end up as valid numbers in the cell.

2. More importantly: each number format string may consist of *four* parts: for
positive numbers; negative numbers; zero; and text. If you omit any part, it is
*not* considered "absent", but a default value is implicitly used for the
respective part. So your partial format string MM/DD/YYYY in reality is equal
to something like "MM/DD/YYYY;MM/DD/YYYY;MM/DD/YYYY;@", where the last fourth
part tells "show text as it was entered". So any text is *valid* from the
format point of view. And there is no way to make it invalid. Any data
*matches* any format string. And format string *has no idea* why the program
decided that this cell is a text.

But you may use custom format string like e.g.
"MM/DD/YYYY;MM/DD/YYYY;MM/DD/YYYY;[red]@", which would mark red all texts,
regardless of the reason why it is text. You may learn more about format
strings in help:
https://help.libreoffice.org/latest/en-US/text/shared/01/05020301.html?&DbPAR=CALC

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/libreoffice-bugs/attachments/20210909/1e335c31/attachment.htm>


More information about the Libreoffice-bugs mailing list