Bug 148223 - Calc allows date 36/04/2021
Summary: Calc allows date 36/04/2021
Status: RESOLVED NOTABUG
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
6.4.7.2 release
Hardware: All All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-03-27 20:09 UTC by Jonny Grant
Modified: 2022-11-14 14:26 UTC (History)
2 users (show)

See Also:
Crash report or crash signature:


Attachments
Test case (8.52 KB, application/vnd.oasis.opendocument.spreadsheet)
2022-03-27 20:09 UTC, Jonny Grant
Details
New Test Document (18.80 KB, application/vnd.oasis.opendocument.spreadsheet)
2022-03-29 09:06 UTC, Rainer Bielefeld Retired
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jonny Grant 2022-03-27 20:09:05 UTC
Created attachment 179151 [details]
Test case

Please reproduce in latest version.

Calc allows date 36/04/2021

I'll attach the ODS file.
Just amend the A1 cell to say 36/04/2021 and note it is not rejected, and it still keeps the same type as "Date" in format cells, even though it is invalid
Comment 1 Rainer Bielefeld Retired 2022-03-29 09:06:42 UTC
Created attachment 179181 [details]
New Test Document

Well, "36/04/2021" is a simple string typed into a cell with user-selected formatting 'Date T. MMM JJJJ'. Also "04/04/2021" will not be recognized as a date (or number) in A1. It only looks like a date if you type that. 
Of course we can discuss whether some more clever "auto date recognition" might be useful, but without a very thoughtful concept that might cause more problems than aid.

Looks INVALID
Comment 2 Jonny Grant 2022-03-29 10:31:08 UTC
Rainer
Many thanks for your reply.

Why is "36/04/2021" not rejected, as it is formatted as a Date? The format doesn't change to Text.

Usually if I type something invalid, Calc shows "Err:511" etc
Why can't it show a similar error, when someone mistypes a Date?

It's one of the perennial problems in Calc, even SUM ignores boxes with text, without an error. (ie for whatever reason a number is entered in a cell that is formatted as Text - so then SUM ignores it - means accounts are wrong)
Cheers
Comment 3 Mike Kaganski 2022-11-14 13:38:48 UTC
(In reply to Jonny Grant from comment #2)
> Why is "36/04/2021" not rejected, as it is formatted as a Date? The format
> doesn't change to Text.

Because Calc does not insist on converting any string that you type into the cell into a number, no matter how the cell is formatted. You may format a cell as Date, and type "Lorem ipsum" into it, and it will not turn into an error.

Any entered string is *checked* if it's convertible into a number, if the cell formatting allows; but when the detection tells that no, it's not possible to convert, then the string is accepted as is, as a string.

And no, Calc does not "show "Err:511" etc" when you "type something invalid"; only produces errors when *a formula* is erroneous or produces an error. And then, the same logic applies - the entered string it attempted to be converted into a formula; and when it starts with specific characters (= or - or +), it *can*, so then the error handling and display is appropriate.

This is the correct behavior. Closing NOTABUG.
Comment 4 Jonny Grant 2022-11-14 14:26:34 UTC
Fair enough. It's not strict like I'd hope, but that's the way it is.