Bug 143979 - FORMATTING: Date format is mangled when file is closed and reopened
Summary: FORMATTING: Date format is mangled when file is closed and reopened
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
Inherited From OOo
Hardware: All All
: medium normal
Assignee: Eike Rathke
URL:
Whiteboard: target:7.3.0 target:7.2.1
Keywords:
Depends on:
Blocks:
 
Reported: 2021-08-20 17:19 UTC by Shad Sterling
Modified: 2021-09-19 14:25 UTC (History)
2 users (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Shad Sterling 2021-08-20 17:19:11 UTC
Description:
I habitually format date cells as `YYYY-MM""MMM-DDNN` (where the `""` acts as a separator between `MM` and `MMM`), so today appears as `2021-08Aug-20Fri`

In some files, every time I close and reopen the file the date cell formats have reverted to `YYYY-MMMMM-DDNN` (where `MMMMM` is expanded to the first letter of `MMM`), so today appears as `2021-A-20Fri`

The format it saved with also does not appear in the list of formats in the Format Cells dialog

Steps to Reproduce:
1. Format some dates with `YYYY-MM""MMM-DDNN`
2. Save and close
3. Reopen

For some files it does it every time, for other files it never does it, I have no idea what the difference is

Actual Results:
All my dates got reformatted

Expected Results:
All my formats should be preserved


Reproducible: Always


User Profile Reset: No



Additional Info:
Version: 7.1.4.2 / LibreOffice Community
Build ID: a529a4fab45b75fefc5b6226684193eb000654f6
CPU threads: 16; OS: Mac OS X 10.16; UI render: default; VCL: osx
Locale: en-US (en_US.UTF-8); UI: en-US
Calc: threaded
Comment 1 Eike Rathke 2021-08-20 21:40:18 UTC
Seems the empty string is eliminated while saving the format description and that ends up as

      <number:month number:style="long"/>
      <number:month number:textual="true"/>

i.e. two consecutive month elements for MM and MMM which when read in correctly form MMMMM.

Workaround: use U+200B ZERO WIDTH SPACE, ZWSP in your quotes.
This looks the same
YYYY-MM"​"MMM-DDNN
but if you copy-paste it and travel through with the cursor you'll notice one extra character where the cursor does not move.

that is saved and preserved when loaded:

      <number:month number:style="long"/>
      <number:text><200b></number:text>
      <number:month number:textual="true"/>
Comment 2 Commit Notification 2021-08-22 21:15:01 UTC
Eike Rathke committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/c6f15d228489ccfd0628ca80b45a5c2faaacc7d3

Resolves: tdf#143979 Write and read empty text element in number formats

It will be available in 7.3.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 3 Eike Rathke 2021-08-22 21:15:31 UTC
Pending review https://gerrit.libreoffice.org/c/core/+/120728 for 7-2
Comment 4 Commit Notification 2021-08-24 07:24:47 UTC Comment hidden (obsolete)
Comment 5 Xisco Faulí 2021-08-24 07:32:18 UTC
The unittest commit in comment 4 is not for this issue but for bug 144022
Comment 6 Commit Notification 2021-08-25 07:55:26 UTC
Eike Rathke committed a patch related to this issue.
It has been pushed to "libreoffice-7-2":

https://git.libreoffice.org/core/commit/5d6a91b8ea40ec79c746e5c1d486be6e25a2856d

Resolves: tdf#143979 Write and read empty text element in number formats

It will be available in 7.2.1.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 7 Commit Notification 2021-08-25 17:20:59 UTC
Xisco Fauli committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/fba08b85183ee8a71f6b7044d6fa4492c0cc1be8

tdf#143979: sc_subsequent_export-test2: Add unittest

It will be available in 7.3.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 8 Shad Sterling 2021-09-19 14:25:41 UTC
This does appear to be fixed in build 559850da1f48fd7ea521c78a1867255212f7aee9

In the current release, I can also get dates to render as intended with `YYYY-MM""MMM-DD""NN`, apparently the second `""` makes it work.

The zero-width space is rendered as a grey shading which overlaps the neighboring characters, which is far enough from rendering as intended that I tried using the `""`