xmloff/source/core/xmluconv.cxx | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
New commits: commit 0c3f57487c9cc29d172121b178938cdb2a8adc7b Author: Eike Rathke <er...@redhat.com> AuthorDate: Wed Nov 29 19:11:22 2023 +0100 Commit: Eike Rathke <er...@redhat.com> CommitDate: Wed Nov 29 23:56:53 2023 +0100 Resolves: tdf#158265 Store more than 100th seconds precision in date+time e.g. office:date-value Change-Id: I9bb4b589cdb8c6f04fa39ba7ec4254207eaa3663 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160124 Reviewed-by: Eike Rathke <er...@redhat.com> Tested-by: Jenkins diff --git a/xmloff/source/core/xmluconv.cxx b/xmloff/source/core/xmluconv.cxx index a95de5ecb66c..544bea50d3c5 100644 --- a/xmloff/source/core/xmluconv.cxx +++ b/xmloff/source/core/xmluconv.cxx @@ -61,7 +61,6 @@ using namespace ::com::sun::star::i18n; using namespace ::xmloff::token; -const sal_Int8 XML_MAXDIGITSCOUNT_TIME = 11; constexpr OUStringLiteral XML_NULLDATE = u"NullDate"; struct SvXMLUnitConverter::Impl @@ -444,6 +443,16 @@ void SvXMLUnitConverter::convertDateTime( OUStringBuffer& rBuffer, else fCount = 0.0; const int nDigits = sal_Int16(fCount) + 4; // +4 for *86400 in seconds + + // Since the beginning from initial source code import this was 11 without + // further explanation, effectively limiting fractions in ~current + // date+time to 2 decimals (maybe because old class Time code had a + // resolution of only 100th seconds). Preserve at least milliseconds, but + // strive for more. + // NOTE: sax/source/tools/converter.cxx uses 14-5 in a different context + // rounding nanoseconds and fractions of seconds. + constexpr int XML_MAXDIGITSCOUNT_TIME = 14; + const int nFractionDecimals = std::max( XML_MAXDIGITSCOUNT_TIME - nDigits, 0); sal_uInt16 nHour, nMinute, nSecond;