comphelper/source/misc/date.cxx |    8 +++++---
 tools/source/datetime/tdate.cxx |    8 +++-----
 2 files changed, 8 insertions(+), 8 deletions(-)

New commits:
commit fb022d3ba4acc78f7eaa01c81d8fdfbed53b4315
Author:     Mike Kaganski <[email protected]>
AuthorDate: Thu Sep 11 11:31:20 2025 +0200
Commit:     Mike Kaganski <[email protected]>
CommitDate: Thu Sep 11 14:55:51 2025 +0200

    Use less magic numbers
    
    The constexpr function can generate them better
    
    Change-Id: Iff25750a4f20181cca5c42c47884d68933229e74
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/190807
    Reviewed-by: Mike Kaganski <[email protected]>
    Tested-by: Jenkins

diff --git a/comphelper/source/misc/date.cxx b/comphelper/source/misc/date.cxx
index b95f63f75c97..2625d32c1d2f 100644
--- a/comphelper/source/misc/date.cxx
+++ b/comphelper/source/misc/date.cxx
@@ -36,12 +36,14 @@ namespace comphelper::date
 /* XXX can that dbconversion cope with years > 9999 or negative years at all?
  * Database fields may be limited to positive 4 digits. */
 
-constexpr sal_Int32 MIN_DAYS = -11968265; // -32768-01-01
-constexpr sal_Int32 MAX_DAYS = 11967900; //  32767-12-31
-
 constexpr sal_Int16 kYearMax = SAL_MAX_INT16;
 constexpr sal_Int16 kYearMin = SAL_MIN_INT16;
 
+constexpr sal_Int32 MIN_DAYS = convertDateToDays(1, 1, kYearMin); // 
-32768-01-01
+static_assert(MIN_DAYS == -11968265);
+constexpr sal_Int32 MAX_DAYS = convertDateToDays(31, 12, kYearMax); // 
32767-12-31
+static_assert(MAX_DAYS == 11967900);
+
 constexpr sal_Int32 nNullDateDays = convertDateToDays(30, 12, 1899);
 static_assert(nNullDateDays == 693594);
 
diff --git a/tools/source/datetime/tdate.cxx b/tools/source/datetime/tdate.cxx
index 92da1cd3d42a..3d543c8cc47e 100644
--- a/tools/source/datetime/tdate.cxx
+++ b/tools/source/datetime/tdate.cxx
@@ -72,11 +72,9 @@ sal_Int32 Date::GetAsNormalizedDays() const
     // This is a very common datum we often calculate from.
     if (mnDate == 18991230) // 1899-12-30
     {
-#ifndef NDEBUG
-        static sal_Int32 nDays = DateToDays( GetDay(), GetMonth(), GetYear());
-        assert(nDays == 693594);
-#endif
-        return 693594;
+        assert(GetDay() == 30 && GetMonth() == 12 && GetYear() == 1899);
+        constexpr sal_Int32 nullDays = comphelper::date::convertDateToDays(30, 
12, 1899);
+        return nullDays;
     }
     // Not calling comphelper::date::convertDateToDaysNormalizing() here just
     // avoids a second check on null-date handling like above.

Reply via email to