Bug 83752 - FORMATTING: date/time modification causes the cell format to be string text in Simplified Chinese locale
Summary: FORMATTING: date/time modification causes the cell format to be string text i...
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
4.2.6.2 release
Hardware: All All
: medium normal
Assignee: Kevin Suo
URL:
Whiteboard: BSA target:4.4.0.0.beta3 target:4.3.5
Keywords:
Depends on:
Blocks: CJK
  Show dependency treegraph
 
Reported: 2014-09-11 07:37 UTC by chenwenkovski
Modified: 2014-12-18 13:04 UTC (History)
1 user (show)

See Also:
Crash report or crash signature:


Attachments
document (23.27 KB, application/vnd.oasis.opendocument.spreadsheet)
2014-09-11 07:37 UTC, chenwenkovski
Details

Note You need to log in before you can comment on or make changes to this bug.
Description chenwenkovski 2014-09-11 07:37:58 UTC
Created attachment 106108 [details]
document

Problem description: 
In Chinese environment, when I use ctrl+; to insert a time, and I change it, it will make mistakes. it goes right that I change the cell's language into English.

Steps to reproduce:
1. [A1]ctrl+; [B1]ctrl+; [C1]=B1-A1, format is [HH]:MM

2. change [B1]'s hour or minite, it make [C1] error like '#VALUE!'. Look at [B1], it like strings.

Current behavior:
#VALUE!

Expected behavior:
recompute and show me a time like "40:21"
              
Operating System: Windows 7
Version: 4.2.6.2 release
Comment 1 Kevin Suo 2014-12-03 09:49:01 UTC
Reproduced. 

Steps to reproduce:

1. Make sure you set your locale to Simplified Chinese (Tools - Options - Language Settings - Languages - Locale")

2. In A1, type in "2014-12-03 17:39" and hit ENTER.

--> The cell value will show as "2014年12月3日17时39分00秒", while in the formula bar it shows "14年12月3日17时39分". 
Please note that now the value in cell A1 is in date format (i.e., you can use A1 to do calculations). 
(This is expected)

3. Change "2014年12月3日17时39分" to "2014年12月3日17时40分".

--> The value in A1 becomes text strings. This is a bug behaviour.

Actually if you type in "2014年12月3日17时40分" in a cell, it will never be formatted as date/time format.

I believe this has something to do with zh-CN locale data here:
http://cgit.freedesktop.org/libreoffice/core/tree/i18npool/source/localedata/data/zh_CN.xml
because in other locales I do not reproduce this.

I assign this to me myself.
Comment 2 Kevin Suo 2014-12-03 10:12:07 UTC
http://cgit.freedesktop.org/libreoffice/core/tree/i18npool/source/localedata/data/zh_CN.xml

    <!-- Date formats. Index range is from 18 to 38 -->
    <FormatElement msgid="DateFormatskey1" default="true" type="medium" usage="DATE" formatindex="18">
      <FormatCode>YY"年"M"月"D"日"</FormatCode>
    </FormatElement>

and

    <!-- Date_Time formats. Index range is from 46 to 47. -->
    <FormatElement msgid="DateTimeFormatskey4" default="true" type="long" usage="DATE_TIME"  formatindex="46">
      <FormatCode>YYYY"年"MM"月"D"日"HH"时"MM"分"SS"秒"</FormatCode>
    </FormatElement>

Needs to be revised.


      <FormatCode>YYYY/M/D</FormatCode>
and
      <FormatCode>YYYY/M/D HH:MM</FormatCode>
are better choices.
Comment 3 Kevin Suo 2014-12-04 06:15:21 UTC
Just for information:

https://wiki.openoffice.org/wiki/Documentation/DevGuide/OfficeDev/Implementing_a_New_Locale

"
<FormatCode usage="DATE" formatindex="21"> and <FormatCode usage="DATE_TIME" formatindex="47">

    The formatindex="21" ... format code is used to edit date formatted data. It represents a date using the most detailed information available, for example, a 4-digit year and instead of a 2-digit year...
 
    Similarly, the formatindex="47" ... format code is used to edit date-time data. Both format codes must display data in a way that is parable by the application, in order to be able to reassemble edited data. This generally means using only YYYY,MM,DD,HH,MM,SS keywords and <DateSeparator> and <TimeSeparator>...
"

So here is the problem:
    <FormatElement msgid="DateTimeFormatskey3" default="false" type="long" usage="DATE_TIME"  formatindex="47">
      <FormatCode>YY"年"M"月"D"日"HH"时"MM"分"</FormatCode>
    </FormatElement>

In the above entry, [YY"年"M"月"D"日"HH"时"MM"分"] does contain YYYY,MM,DD,HH,MM, but does NOT contain SS. so when editing the time libreoffice does not realize that this is a date-and-time format, thus results a string text format.

I assume some other locales many have the same issue.
Comment 4 Kevin Suo 2014-12-04 08:44:07 UTC
Changes submitted to master for review:
https://gerrit.libreoffice.org/#/c/13296/

I will do the backport to 4.3/4.2 only if it's verified that this patch works fine with master daily.
Comment 5 Commit Notification 2014-12-05 15:33:44 UTC
Kevin Suo committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=d00a3722b46314c927ba392a31fe4ff5ebc5c0b5

fdo#83752: date-time cell becomes text string when editing, zh_CN locale

It will be available in 4.5.0.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds
Affected users are encouraged to test the fix and report feedback.
Comment 6 Commit Notification 2014-12-05 15:36:07 UTC
Kevin Suo committed a patch related to this issue.
It has been pushed to "libreoffice-4-4":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=fabdb9356fe2b4d04b7e3ae4f2bfbd92fc306d76&h=libreoffice-4-4

fdo#83752: date-time cell becomes text string when editing, zh_CN locale

It will be available in 4.4.0.0.beta3.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds
Affected users are encouraged to test the fix and report feedback.
Comment 7 Commit Notification 2014-12-05 15:46:19 UTC
Kevin Suo committed a patch related to this issue.
It has been pushed to "libreoffice-4-3":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=9ac54387bcee173e0af448d71b8890e5e255285c&h=libreoffice-4-3

fdo#83752: date-time cell becomes text string when editing, zh_CN locale

It will be available in 4.3.6.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds
Affected users are encouraged to test the fix and report feedback.
Comment 8 Eike Rathke 2014-12-05 15:48:48 UTC
Pending review for 4-3-5 at https://gerrit.libreoffice.org/13314
Comment 9 Commit Notification 2014-12-09 09:17:04 UTC
Kevin Suo committed a patch related to this issue.
It has been pushed to "libreoffice-4-3-5":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=71f4f4b36f41fbd59fd122de0ce29361f20ee37f&h=libreoffice-4-3-5

fdo#83752: date-time cell becomes text string when editing, zh_CN locale

It will be available in 4.3.5.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds
Affected users are encouraged to test the fix and report feedback.
Comment 10 Adolfo Jayme Barrientos 2014-12-18 13:04:18 UTC
(Removing redundant whiteboard “target” entries (something the old commit notification bot did automatically)