Bug 142464 - Date format from MS Word not imported correctly
Summary: Date format from MS Word not imported correctly
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: Mike Kaganski
URL:
Whiteboard: target:7.3.0 target:7.2.0.0.beta2
Keywords:
Depends on:
Blocks:
 
Reported: 2021-05-24 12:55 UTC by Jack O'Sullivan
Modified: 2021-07-11 13:23 UTC (History)
4 users (show)

See Also:
Crash report or crash signature:


Attachments
docx with date fields (15.22 KB, application/vnd.openxmlformats-officedocument.wordprocessingml.document)
2021-05-24 12:55 UTC, Jack O'Sullivan
Details
Screenshoot (320.69 KB, image/png)
2021-05-24 13:31 UTC, m_a_riosv
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jack O'Sullivan 2021-05-24 12:55:53 UTC
Created attachment 172294 [details]
docx with date fields

I have a date-time field in a docx (created in MS Word 365) which is formatted with the string:

TIME \@ "M/d/yyyy h:mm am/pm" \* MERGEFORMAT

which displays correctly in Word as:

(e.g.) 5/24/2021 1:55 PM

When I open this document in LibreOffice (tested with 5.3.7.2 on Linux and 7.0.6.2 on Windows with the same outcome in each) the date-time displays as:

(e.g.) 5/24/2021 13:55 a5/p5

This suggests that the am/pm marker from the MS format isn't being recognized as an instruction to use a 12hr clock and display the am/pm marker, but rather than it should use a 24hr clock and display the a and p as literal strings and interpret the "m" as a month marker.

This behavior is also observed when running a command line "convert-to" odt.

I have attached the original docx to enable re-production. This docx also demonstrates related date-time bugs for tickets:

136347 - (See Last Print Time in attached docx)
65209 - (When converting to ODT, TZ info is lost)
Comment 1 Xisco Faulí 2021-05-24 13:25:14 UTC
Reproduced in

Version: 7.2.0.0.alpha1+ / LibreOffice Community
Build ID: 42d2b2d55a27f11153ea1713737d93540a19211d
CPU threads: 4; OS: Linux 5.7; UI render: default; VCL: gtk3
Locale: en-US (en_US.UTF-8); UI: en-US
Calc: threaded

Version: 5.2.0.0.alpha0+
Build ID: 3ca42d8d51174010d5e8a32b96e9b4c0b3730a53
Threads 4; Ver: 5.7; Render: default;

and

Version 4.1.0.0.alpha0+ (Build ID: efca6f15609322f62a35619619a6d5fe5c9bd5a)
Comment 2 m_a_riosv 2021-05-24 13:31:08 UTC
Created attachment 172295 [details]
Screenshoot

This is what I see, I think no issue.
Comment 3 m_a_riosv 2021-05-24 13:36:47 UTC
Sorry to quick, reproducible on the last line.
Comment 4 Mike Kaganski 2021-07-04 08:53:18 UTC
It *seems* that a string like "am\\/pm" is not matched against a keyword "AM/PM", because of the backslash? It seems to happen in ImpSvNumberformatScan::GetKeyWord. No idea if it's safe to strip backslashes from strings at any of the stages up to the keyword detection...
Comment 5 Mike Kaganski 2021-07-04 09:31:41 UTC
https://gerrit.libreoffice.org/c/core/+/118369
Comment 6 Commit Notification 2021-07-04 12:17:37 UTC
Mike Kaganski committed a patch related to this issue.
It has been pushed to "master":

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

tdf#142464: do not escape '/' is AM/PM when importing DOCX.

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 7 Mike Kaganski 2021-07-04 13:25:58 UTC
FTR - was repro also in OOo 3.1.1.
Comment 8 Commit Notification 2021-07-06 09:33:25 UTC
Mike Kaganski committed a patch related to this issue.
It has been pushed to "libreoffice-7-2":

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

tdf#142464: do not escape '/' is AM/PM when importing DOCX.

It will be available in 7.2.0.0.beta2.

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 BogdanB 2021-07-11 13:23:39 UTC
Verified. Working well in
Version: 7.3.0.0.alpha0+ / LibreOffice Community
Build ID: eac5977bfc11797eda356560a5e45c51108ef5a1
CPU threads: 4; OS: Linux 5.8; UI render: default; VCL: gtk3
Locale: ro-RO (ro_RO.UTF-8); UI: en-US
Calc: threaded

AM/PM instead of A7/P7