diff options
-rw-r--r-- | sax/source/tools/converter.cxx | 18 | ||||
-rw-r--r-- | sc/qa/unit/data/functions/date_time/fods/time.fods | 169 |
2 files changed, 13 insertions, 174 deletions
diff --git a/sax/source/tools/converter.cxx b/sax/source/tools/converter.cxx index bc2342d5b508..990e31e20d4f 100644 --- a/sax/source/tools/converter.cxx +++ b/sax/source/tools/converter.cxx @@ -35,6 +35,7 @@ #include <o3tl/unit_conversion.hxx> #include <osl/diagnose.h> #include <tools/long.hxx> +#include <tools/time.hxx> #include <algorithm> #include <string_view> @@ -976,16 +977,13 @@ static bool convertDurationHelper(double& rfTime, V pStr) if ( bSuccess ) { - if ( nDays ) - nHours += nDays * 24; // add the days to the hours part - double fHour = nHours; - double fMin = nMins; - double fSec = nSecs; - double fFraction = o3tl::toDouble(sDoubleStr); - double fTempTime = fHour / 24; - fTempTime += fMin / (24 * 60); - fTempTime += fSec / (24 * 60 * 60); - fTempTime += fFraction / (24 * 60 * 60); + // Calculate similar to ImpSvNumberInputScan::GetTimeRef: first, sum whole seconds, add + // second fraction, and finally, divide. Produces less rounding errors than calculating + // fractions of a day from seconds, minutes, hours separately, and then adding together. + double seconds = nDays * tools::Time::secondPerDay + nHours * tools::Time::secondPerHour + + nMins * tools::Time::secondPerMinute + nSecs + + o3tl::toDouble(sDoubleStr); + double fTempTime = seconds / tools::Time::secondPerDay; // negative duration? if ( bIsNegativeDuration ) diff --git a/sc/qa/unit/data/functions/date_time/fods/time.fods b/sc/qa/unit/data/functions/date_time/fods/time.fods index f2f2df5512a9..40e60f1271f0 100644 --- a/sc/qa/unit/data/functions/date_time/fods/time.fods +++ b/sc/qa/unit/data/functions/date_time/fods/time.fods @@ -748,9 +748,11 @@ <table:table-cell table:number-columns-repeated="4"/> </table:table-row> <table:table-row table:style-name="ro2"> - <table:table-cell table:number-columns-repeated="2"/> - <table:table-cell table:style-name="ce19"/> - <table:table-cell table:number-columns-repeated="7"/> + <table:table-cell table:style-name="ce13" table:formula="of:=TIME(14;30;0)" office:value-type="time"/> + <table:table-cell table:style-name="ce16" office:value-type="time" office:time-value="PT14H30M00S"/> + <table:table-cell table:style-name="ce17" table:formula="of:=ORG.LIBREOFFICE.RAWSUBTRACT([.A11];[.B11])=0" office:value-type="boolean"/> + <table:table-cell table:style-name="ce21" table:formula="of:=FORMULA([.A11])" office:value-type="string"/> + <table:table-cell table:number-columns-repeated="6"/> <table:table-cell office:value-type="float" office:value="19" calcext:value-type="float"> <text:p>19</text:p> </table:table-cell> @@ -772,167 +774,6 @@ <table:table-cell table:style-name="ce19"/> <table:table-cell table:number-columns-repeated="12"/> </table:table-row> - <table:table-row table:style-name="ro2" table:number-rows-repeated="2"> - <table:table-cell table:style-name="ce14" table:number-columns-repeated="2"/> - <table:table-cell table:style-name="ce20"/> - <table:table-cell table:style-name="ce14" table:number-columns-repeated="2"/> - <table:table-cell table:number-columns-repeated="10"/> - </table:table-row> - <table:table-row table:style-name="ro2"> - <table:table-cell table:style-name="ce15" table:number-columns-repeated="5"/> - <table:table-cell table:number-columns-repeated="4"/> - <table:table-cell table:style-name="ce22" table:number-columns-repeated="6"/> - </table:table-row> - <table:table-row table:style-name="ro2"> - <table:table-cell table:style-name="ce14" table:number-columns-repeated="5"/> - <table:table-cell table:number-columns-repeated="10"/> - </table:table-row> - <table:table-row table:style-name="ro2"> - <table:table-cell table:style-name="ce14" table:number-columns-repeated="2"/> - <table:table-cell table:style-name="ce20"/> - <table:table-cell table:style-name="ce14" table:number-columns-repeated="2"/> - <table:table-cell table:number-columns-repeated="10"/> - </table:table-row> - <table:table-row table:style-name="ro2"> - <table:table-cell table:style-name="ce14" table:number-columns-repeated="2"/> - <table:table-cell table:style-name="ce20"/> - <table:table-cell table:style-name="ce14" table:number-columns-repeated="2"/> - <table:table-cell table:number-columns-repeated="4"/> - <table:table-cell table:style-name="ce22" table:number-columns-repeated="5"/> - <table:table-cell/> - </table:table-row> - <table:table-row table:style-name="ro2"> - <table:table-cell table:number-columns-repeated="2"/> - <table:table-cell table:style-name="ce19"/> - <table:table-cell table:number-columns-repeated="6"/> - <table:table-cell table:style-name="ce24"/> - <table:table-cell table:number-columns-repeated="5"/> - </table:table-row> - <table:table-row table:style-name="ro2"> - <table:table-cell table:number-columns-repeated="2"/> - <table:table-cell table:style-name="ce19"/> - <table:table-cell table:number-columns-repeated="12"/> - </table:table-row> - <table:table-row table:style-name="ro2"> - <table:table-cell table:number-columns-repeated="2"/> - <table:table-cell table:style-name="ce19"/> - <table:table-cell table:number-columns-repeated="6"/> - <table:table-cell table:style-name="ce22" table:number-columns-repeated="5"/> - <table:table-cell/> - </table:table-row> - <table:table-row table:style-name="ro2" table:number-rows-repeated="2"> - <table:table-cell table:number-columns-repeated="2"/> - <table:table-cell table:style-name="ce19"/> - <table:table-cell table:number-columns-repeated="12"/> - </table:table-row> - <table:table-row table:style-name="ro2"> - <table:table-cell table:number-columns-repeated="2"/> - <table:table-cell table:style-name="ce19"/> - <table:table-cell table:number-columns-repeated="6"/> - <table:table-cell table:style-name="ce22" table:number-columns-repeated="5"/> - <table:table-cell/> - </table:table-row> - <table:table-row table:style-name="ro2" table:number-rows-repeated="6"> - <table:table-cell table:number-columns-repeated="2"/> - <table:table-cell table:style-name="ce19"/> - <table:table-cell table:number-columns-repeated="12"/> - </table:table-row> - <table:table-row table:style-name="ro2"> - <table:table-cell table:number-columns-repeated="2"/> - <table:table-cell table:style-name="ce19"/> - <table:table-cell table:number-columns-repeated="6"/> - <table:table-cell table:style-name="ce22" table:number-columns-repeated="5"/> - <table:table-cell/> - </table:table-row> - <table:table-row table:style-name="ro2" table:number-rows-repeated="4"> - <table:table-cell table:number-columns-repeated="2"/> - <table:table-cell table:style-name="ce19"/> - <table:table-cell table:number-columns-repeated="12"/> - </table:table-row> - <table:table-row table:style-name="ro2"> - <table:table-cell table:number-columns-repeated="2"/> - <table:table-cell table:style-name="ce19"/> - <table:table-cell table:number-columns-repeated="6"/> - <table:table-cell table:style-name="ce22" table:number-columns-repeated="5"/> - <table:table-cell/> - </table:table-row> - <table:table-row table:style-name="ro2" table:number-rows-repeated="2"> - <table:table-cell table:number-columns-repeated="2"/> - <table:table-cell table:style-name="ce19"/> - <table:table-cell table:number-columns-repeated="12"/> - </table:table-row> - <table:table-row table:style-name="ro2"> - <table:table-cell table:number-columns-repeated="2"/> - <table:table-cell table:style-name="ce19"/> - <table:table-cell table:number-columns-repeated="6"/> - <table:table-cell table:style-name="ce22" table:number-columns-repeated="5"/> - <table:table-cell/> - </table:table-row> - <table:table-row table:style-name="ro2"> - <table:table-cell table:number-columns-repeated="2"/> - <table:table-cell table:style-name="ce19"/> - <table:table-cell table:number-columns-repeated="12"/> - </table:table-row> - <table:table-row table:style-name="ro2"> - <table:table-cell table:number-columns-repeated="15"/> - </table:table-row> - <table:table-row table:style-name="ro2"> - <table:table-cell table:number-columns-repeated="9"/> - <table:table-cell table:style-name="ce22" table:number-columns-repeated="5"/> - <table:table-cell/> - </table:table-row> - <table:table-row table:style-name="ro2" table:number-rows-repeated="2"> - <table:table-cell table:number-columns-repeated="15"/> - </table:table-row> - <table:table-row table:style-name="ro2"> - <table:table-cell table:number-columns-repeated="9"/> - <table:table-cell table:style-name="ce22" table:number-columns-repeated="5"/> - <table:table-cell/> - </table:table-row> - <table:table-row table:style-name="ro2" table:number-rows-repeated="2"> - <table:table-cell table:number-columns-repeated="15"/> - </table:table-row> - <table:table-row table:style-name="ro2"> - <table:table-cell table:number-columns-repeated="9"/> - <table:table-cell table:style-name="ce22" table:number-columns-repeated="5"/> - <table:table-cell/> - </table:table-row> - <table:table-row table:style-name="ro2" table:number-rows-repeated="2"> - <table:table-cell table:number-columns-repeated="15"/> - </table:table-row> - <table:table-row table:style-name="ro2"> - <table:table-cell table:number-columns-repeated="9"/> - <table:table-cell table:style-name="ce22" table:number-columns-repeated="5"/> - <table:table-cell/> - </table:table-row> - <table:table-row table:style-name="ro2" table:number-rows-repeated="2"> - <table:table-cell table:number-columns-repeated="15"/> - </table:table-row> - <table:table-row table:style-name="ro2"> - <table:table-cell table:number-columns-repeated="9"/> - <table:table-cell table:style-name="ce22" table:number-columns-repeated="5"/> - <table:table-cell/> - </table:table-row> - <table:table-row table:style-name="ro2" table:number-rows-repeated="2"> - <table:table-cell table:number-columns-repeated="15"/> - </table:table-row> - <table:table-row table:style-name="ro2"> - <table:table-cell table:number-columns-repeated="9"/> - <table:table-cell table:style-name="ce25" table:number-columns-repeated="5"/> - <table:table-cell table:style-name="ce26" office:value-type="string" calcext:value-type="string"> - <text:p>Age</text:p> - </table:table-cell> - </table:table-row> - <table:table-row table:style-name="ro2" table:number-rows-repeated="2"> - <table:table-cell table:number-columns-repeated="9"/> - <table:table-cell table:style-name="ce26" table:number-columns-repeated="6"/> - </table:table-row> - <table:table-row table:style-name="ro2" table:number-rows-repeated="1048515"> - <table:table-cell table:number-columns-repeated="15"/> - </table:table-row> - <table:table-row table:style-name="ro2"> - <table:table-cell table:number-columns-repeated="15"/> - </table:table-row> <calcext:conditional-formats> <calcext:conditional-format calcext:target-range-address="Sheet2.C18:Sheet2.C41 Sheet2.C2:Sheet2.C15"> <calcext:condition calcext:apply-style-name="Default" calcext:value="=""" calcext:base-cell-address="Sheet2.C2"/> |