Bug 91405 - calc does not save explicitly defined cell formatting for date functions
Summary: calc does not save explicitly defined cell formatting for date functions
Status: CLOSED WORKSFORME
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
4.4.2.2 release
Hardware: Other All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: Number-Format
  Show dependency treegraph
 
Reported: 2015-05-20 09:39 UTC by lvm
Modified: 2017-10-02 05:31 UTC (History)
2 users (show)

See Also:
Crash report or crash signature:


Attachments
testcase (9.25 KB, application/vnd.oasis.opendocument.spreadsheet)
2015-05-21 06:38 UTC, lvm
Details

Note You need to log in before you can comment on or make changes to this bug.
Description lvm 2015-05-20 09:39:27 UTC
Consider the following scenario:

1. Set a cell value to =now() - default date format is applied automatically
2. Change format to number, general - now cell displays a number of days since 1-1-1900
3. Save, close, reopen - formatting is lost, default date format is applied again

Explicit formatting should be retained and may not be changed automatically. Same problem with other date functions - today(), date(), etc, if however cell value is an expression e.g. =now()+0 everything works fine.
Comment 1 raal 2015-05-20 12:22:31 UTC
Hello,
works for me with LO 4.4.3, win7.
Please test with latest version, https://www.libreoffice.org/download/libreoffice-fresh/
Thank you.
Comment 2 lvm 2015-05-21 06:38:26 UTC
Created attachment 115761 [details]
testcase
Comment 3 lvm 2015-05-21 06:40:41 UTC
Does NOT work for me with 4.4.3.2 windows 7 32-bit. I am attaching a testcase date_autoformat_bug.ods

1. open it
2. set 'number, general' format to cell A1 - format changes to number
3. set 'number, general' format to cell A2 - format changes to number
4. save
5. close
6. open it again - cells A1 and A2 have date formats, not number formats

2 and 3 are separate steps for a reason, this bug manifests itself in another way: if you try selecting cells A1 and A2 and then apply number.general format to this selection format won't change at all.
Comment 4 raal 2015-05-22 07:37:16 UTC
I can confirm now with your file. Weird, when I set =NOW() in another cell then it works for me, even with your file. Looks like it works in another cells, please test it with cell D5=NOW()

Setting to NEW.
Version is oldest.
Comment 5 lvm 2015-05-22 11:51:23 UTC
Yes, I can set numeric format for now() in D5, it is kept after saving and opening, and after that I can set and restore numeric format even in A1. But I still cannot set numeric format for A1:A2 selection. Weird indeed.
Comment 6 QA Administrators 2016-09-20 09:42:21 UTC Comment hidden (obsolete)
Comment 7 lvm 2016-09-21 06:05:11 UTC
still reproducible with 5.2.1.2 for windows
Comment 8 Eike Rathke 2017-09-30 17:09:30 UTC
For cells that are formatted to the standard (non-fixed) General number format a date format is applied when a function is calculated that returns a date/time result. TODAY() and NOW() are always recalculated, hence a format is applied. This won't be changed. Use an explicit number format instead of the General format, or if the automatic decimals are wanted define a format of General;General which also creates a new fixed non-standard format.
Comment 9 lvm 2017-10-02 05:31:21 UTC
Was going to write an angry rejoinder but checked first - this bug is fixed in 5.4.1.2. All manifestations are now gone: format is saved, formatting can be applied to multiple cells, all cells behave in the same manner.