forms/source/xforms/datatypes.cxx | 4 ++-- toolkit/source/controls/table/cellvalueconversion.cxx | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-)
New commits: commit c6af3d93b6f2603f7ea6c898742876198ca557e1 Author: Mike Kaganski <[email protected]> AuthorDate: Thu Sep 11 11:32:50 2025 +0500 Commit: Mike Kaganski <[email protected]> CommitDate: Fri Sep 12 05:09:34 2025 +0200 Use a bit more standard null date The two places in cellvalueconversion.cxx using the null date were introduced in commit a7e949673cda3f0e2abfa49b2c22735f33205d01 (gridfixes: #i117265# use a NumberFormatter for converting cell values to text., 2012-09-14); they are used together, so that the code in lcl_convertDateToDays uses the same epoch as defined in the respective number formatter, and the obtained number value is only ever used inside convertToString in a call to the formatter's convertNumberToString. The old value was arbitrary; and the new value has some optimizations in the code (see Date::DateToDays and comphelper::date::convertDateToDaysNormalizing called from it). Change-Id: I9c050d26ace1cf3fccde579d0d91c00f26bb3fd8 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/190788 Tested-by: Jenkins Reviewed-by: Mike Kaganski <[email protected]> diff --git a/toolkit/source/controls/table/cellvalueconversion.cxx b/toolkit/source/controls/table/cellvalueconversion.cxx index da9a83346565..5a53089bf84e 100644 --- a/toolkit/source/controls/table/cellvalueconversion.cxx +++ b/toolkit/source/controls/table/cellvalueconversion.cxx @@ -60,7 +60,7 @@ namespace double lcl_convertDateToDays(sal_uInt16 const i_day, sal_uInt16 const i_month, sal_Int16 const i_year) { - tools::Long const nNullDateDays = ::Date::DateToDays(1, 1, 1900); + tools::Long const nNullDateDays = ::Date::DateToDays(30, 12, 1899); tools::Long const nValueDateDays = ::Date::DateToDays(i_day, i_month, i_year); return nValueDateDays - nNullDateDays; @@ -280,7 +280,7 @@ bool CellValueConversion::ensureNumberFormatter() = NumberFormatsSupplier::createWithLocale(xContext, aLocale); // ensure a NullDate we will assume later on - css::util::Date const aNullDate(1, 1, 1900); + css::util::Date const aNullDate(30, 12, 1899); Reference<XPropertySet> const xFormatSettings(xSupplier->getNumberFormatSettings(), UNO_SET_THROW); xFormatSettings->setPropertyValue(u"NullDate"_ustr, Any(aNullDate)); commit 89b0b449d8f64aef0a15fe9d1485061a91da7150 Author: Mike Kaganski <[email protected]> AuthorDate: Thu Sep 11 23:29:35 2025 +0500 Commit: Mike Kaganski <[email protected]> CommitDate: Fri Sep 12 05:09:23 2025 +0200 Use a bit more standard null date in lcl_normalizeDateTime This value is only used for dates comparison inside ODateTimeType; _getValue is used in OValueLimitedType_Base::_validate to comnpare to minimal and maximal cached values, and the latter are set using normalizeValue. The choice of null date is ~random, and in theory, we could just normalize using Date::GetAsNormalizedDays(), but the null date close enough to the actual dates has an upside of keepng enough precision for time part - so just use the most used epoch, which gives an optimized GetAsNormalizedDays, and hence, a faster operator-. Change-Id: I35723373107b2786633c7ddb3cfb82a7dcc4deaa Reviewed-on: https://gerrit.libreoffice.org/c/core/+/190827 Tested-by: Jenkins Reviewed-by: Mike Kaganski <[email protected]> diff --git a/forms/source/xforms/datatypes.cxx b/forms/source/xforms/datatypes.cxx index 2e7f1537184d..4739c1ead758 100644 --- a/forms/source/xforms/datatypes.cxx +++ b/forms/source/xforms/datatypes.cxx @@ -980,8 +980,8 @@ namespace xforms ::DateTime aToolsValue(_rValue); double fValue = 0; - // days since 1.1.1900 (which is relatively arbitrary but fixed date) - fValue += ::Date( aToolsValue ) - ::Date( 1, 1, 1900 ); + // days since 1899-12-30 (which is relatively arbitrary but fixed date) + fValue += ::Date( aToolsValue ) - ::Date( 30, 12, 1899 ); // time fValue += aToolsValue.GetTimeInDays(); return fValue;
