Bug 154218 - variable and user field input field mishandles datetime when locale uses decimal commas
Summary: variable and user field input field mishandles datetime when locale uses deci...
Status: VERIFIED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
Inherited From OOo
Hardware: All All
: medium normal
Assignee: Eike Rathke
URL:
Whiteboard: target:7.6.0 target:7.5.3
Keywords:
Depends on:
Blocks: Number-Format Fields-Variable
  Show dependency treegraph
 
Reported: 2023-03-15 21:41 UTC by Peter Gervai
Modified: 2023-04-11 08:21 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 Peter Gervai 2023-03-15 21:41:36 UTC
When using a full datetime format for a variable (fields>>variables>>user field or set variable) like "1999-01-01 11:22:33" it seems the dialog mishandles the decimal point. 

I had my test set to Hungarian, which uses comma (,) as a decimal separator, so the input field for "1999-01-01 12:00" generated a string like "43210,12345" which resulted "1899-12-31 12:00" since the dialog seem to expect english decimal point, as "43210.12345".

Replacing the decimal manually fixed the datetime.
Comment 1 Stéphane Guillou (stragu) 2023-03-30 10:14:01 UTC
Thanks Peter!

Starting from a default document language of en-AU, I reproduced with the steps:
1. Insert > Field > More Fields... > Variables tab > User Field type > Additional formats...
2. In the Format Number dialog that opened: Category = Time, Language = Hungarian, Format = 1999-12-31 13:37:46,000
3. The format code does use the comma, but the preview shows: 1896-08-12 10:22:14.293
4. Press OK
5. Give Name "test_hun" and Value "1999-01-01 12:00", click green tick then Insert.

Result: in-document field displayed as "1899-12-30 00:00:00,000"

Note that the date is wrong as well when using the format without decimals.

Versions:

Version: 7.4.6.2 / LibreOffice Community
Build ID: 5b1f5509c2decdade7fda905e3e1429a67acd63d
CPU threads: 8; OS: Linux 5.15; UI render: default; VCL: gtk3
Locale: en-AU (en_AU.UTF-8); UI: en-US
Calc: threaded

Same in master build from today.

Already the case in OOo 3.3, even though the preset doesn't have decimals.
Comment 2 Stéphane Guillou (stragu) 2023-03-30 10:17:29 UTC
Confirmed the workaround where one replaces the decimal comma by a decimal point in the resulting Value after inserting.
e.g. replacing "36161,5" by "36161.5".

Also reproduced with another language using decimal commas, like French (France).
Comment 3 Commit Notification 2023-04-02 09:29:23 UTC
Eike Rathke committed a patch related to this issue.
It has been pushed to "master":

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

Resolves: tdf#154218 Tie user field content value string to content locale

It will be available in 7.6.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 4 Commit Notification 2023-04-02 09:29:25 UTC
Eike Rathke committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/8c8457526a11fd03ed63a86ecdeeb270d5551049

Related: tdf#154218 Actually use the top format selected

It will be available in 7.6.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 5 Commit Notification 2023-04-02 09:29:28 UTC
Eike Rathke committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/82ed010cd39351adcd4015e2bdd1591aa869cf18

Resolves: tdf#154218 Use the proper document's SwCalc locale for formula field

It will be available in 7.6.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 6 Eike Rathke 2023-04-02 11:03:30 UTC
Pending review https://gerrit.libreoffice.org/c/core/+/149936 for 7-5
Comment 7 Commit Notification 2023-04-05 09:24:41 UTC
Eike Rathke committed a patch related to this issue.
It has been pushed to "libreoffice-7-5":

https://git.libreoffice.org/core/commit/1093fc294ea5a823da4ebcfdafbef3327f9c82bf

Resolves: tdf#154218 Use proper locale for user field and set variable

It will be available in 7.5.3.

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 Commit Notification 2023-04-10 21:59:35 UTC
Eike Rathke committed a patch related to this issue.
It has been pushed to "master":

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

Related: tdf#154218 Use proper locale in SwUserFieldType::PutValue()

It will be available in 7.6.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 9 Commit Notification 2023-04-11 06:04:10 UTC
Eike Rathke committed a patch related to this issue.
It has been pushed to "libreoffice-7-5":

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

Related: tdf#154218 Use proper locale in SwUserFieldType::PutValue()

It will be available in 7.5.3.

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 10 Stéphane Guillou (stragu) 2023-04-11 08:21:28 UTC
Thanks Eike for the fix! Fix verified in:

Version: 7.6.0.0.alpha0+ (X86_64) / LibreOffice Community
Build ID: fc6806c4be8585ce0d35a6b581bf8b3dbf858500
CPU threads: 8; OS: Linux 5.15; UI render: default; VCL: gtk3
Locale: en-AU (en_AU.UTF-8); UI: en-US
Calc: threaded

Peter, please feel free to test the fix in a master build: https://dev-builds.libreoffice.org/daily/master/current.html