sc/source/filter/xml/xmlcelli.cxx | 9 ++++++++- test/source/sheet/xsheetannotation.cxx | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-)
New commits: commit 17379f401118519670525e319fe7b69b255076b8 Author: Pranam Lashkari <lpra...@collabora.com> AuthorDate: Thu Aug 15 02:28:19 2024 +0200 Commit: Caolán McNamara <caolan.mcnam...@collabora.com> CommitDate: Thu Aug 15 10:50:46 2024 +0200 fixed tdf#162471: display comment dates in ods if available Change-Id: I2fe2621458608a2bf6c382397ec5acdaeffe3748 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/171882 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com> diff --git a/sc/source/filter/xml/xmlcelli.cxx b/sc/source/filter/xml/xmlcelli.cxx index 6c739dc42304..252235c7abd1 100644 --- a/sc/source/filter/xml/xmlcelli.cxx +++ b/sc/source/filter/xml/xmlcelli.cxx @@ -918,7 +918,14 @@ void ScXMLTableRowCellContext::SetAnnotation(const ScAddress& rPos) if (rXMLImport.GetMM100UnitConverter().convertDateTime(fDate, mxAnnotationData->maCreateDate)) { SvNumberFormatter* pNumForm = pDoc->GetFormatTable(); - sal_uInt32 nfIndex = pNumForm->GetFormatIndex( NF_DATE_SYS_DDMMYYYY, LANGUAGE_SYSTEM ); + + // Date string is in format ISO 8601 inside <dc:date> + // i.e: 2024-08-14 or 2024-08-14T23:55:06 or 20240814T235506 + // Time always has prefix 'T' + sal_uInt32 nfIndex = pNumForm->GetFormatIndex( + mxAnnotationData->maCreateDate.indexOf('T') > -1 ? NF_DATETIME_SYS_DDMMYYYY_HHMMSS + : NF_DATE_SYS_DDMMYYYY, + LANGUAGE_SYSTEM); OUString aDate; const Color* pColor = nullptr; pNumForm->GetOutputString( fDate, nfIndex, aDate, &pColor ); diff --git a/test/source/sheet/xsheetannotation.cxx b/test/source/sheet/xsheetannotation.cxx index 1ce4e1a7969d..f06ece8fe2a4 100644 --- a/test/source/sheet/xsheetannotation.cxx +++ b/test/source/sheet/xsheetannotation.cxx @@ -47,7 +47,7 @@ void XSheetAnnotation::testGetDate() uno::Reference< sheet::XSheetAnnotation > aSheetAnnotation (init(), UNO_QUERY_THROW); OUString aDate = aSheetAnnotation->getDate(); - CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong date", OUString("01/17/2013"), aDate); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong date", OUString("01/17/2013 00:00:00"), aDate); } void XSheetAnnotation::testGetIsVisible() {