diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2019-05-01 07:22:44 +0300 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2019-05-01 09:40:22 +0200 |
commit | f8472069d451ec001e602bbc5329ad030fae1219 (patch) | |
tree | f7dcf3efddfc2aa77a8cb9de227fe5cc6cd73e78 /sc/source | |
parent | 4931a1e5e365c018a271fcd94f0a743b4fc38c6c (diff) |
tdf#125055: properly round fractions of seconds
... so that 2017-07-10T09:11:02.999999... becomes 2017-07-10T09:11:03,
not 2017-07-10T09:11:02. The latter created duplicated items in pivot
table cache previously.
TODO: check what to do if the times are actually different by 100 ns?
What Excel does then? Should we increase cache item precision?
Change-Id: I622d1c784ee9fddf6b387bec2d8af87bae5668ba
Reviewed-on: https://gerrit.libreoffice.org/71610
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'sc/source')
-rw-r--r-- | sc/source/filter/excel/xepivotxml.cxx | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/sc/source/filter/excel/xepivotxml.cxx b/sc/source/filter/excel/xepivotxml.cxx index 8c263795fe94..dc825f0c836b 100644 --- a/sc/source/filter/excel/xepivotxml.cxx +++ b/sc/source/filter/excel/xepivotxml.cxx @@ -192,8 +192,10 @@ namespace { */ OUString GetExcelFormattedDate( double fSerialDateTime, const SvNumberFormatter& rFormatter ) { - //::sax::Converter::convertDateTime(sBuf, (DateTime(rFormatter.GetNullDate()) + fSerialDateTime).GetUNODateTime(), 0, true); - css::util::DateTime aUDateTime = (DateTime(rFormatter.GetNullDate()) + fSerialDateTime).GetUNODateTime(); + // tdf#125055: properly round the value to seconds when truncating nanoseconds below + constexpr double fHalfSecond = 1 / 86400.0 * 0.5; + css::util::DateTime aUDateTime + = (DateTime(rFormatter.GetNullDate()) + fSerialDateTime + fHalfSecond).GetUNODateTime(); // We need to reset nanoseconds, to avoid string like: "1982-02-18T16:04:47.999999849" aUDateTime.NanoSeconds = 0; OUStringBuffer sBuf; |