Description: i18npool::Calendar_gregorian::getLocalDateTime used in LibreOffice Basic shows the wrong day and year(usually 1950) but the time is correct. Steps to Reproduce: 1. Run this code in libreOffice Basic: Sub Main dim oLocale As New com.sun.star.lang.Locale oLocale.Language = "en" oLocale.Country = "UK" oCal = CreateUnoService("com.sun.star.i18n.LocaleCalendar") oCal.LoadCalendar("gregorian", oLocale) Print "Now(): " & Now() & ", getLocalDateTime(): " & CDate(oCal.getLocalDateTime() ) End Sub Actual Results: Now(): 05.06.2020 19:00:52, getLocalDateTime(): 04.06.1950 19:00:52 Expected Results: Now(): 05.06.2020 19:00:52, getLocalDateTime(): 05.06.2020 19:00:52 Reproducible: Always User Profile Reset: No OpenGL enabled: Yes Additional Info: should show the correct date for the specified locale.
https://opengrok.libreoffice.org/search?project=core&full=getLocalDateTime&defs=&refs=&path=&hist=&type=&xrd= https://opengrok.libreoffice.org/xref/core/i18npool/source/calendar/calendar_gregorian.cxx?r=32343bcb#366 https://opengrok.libreoffice.org/xref/core/i18npool/source/calendar/calendar_gregorian.cxx?r=32343bcb#176 https://unicode-org.github.io/icu-docs/apidoc/released/icu4c/classicu_1_1Calendar.html#a9b5a6f6255101c08f0fd49c0a7063fc2 >This is a primitive data type that holds the date and time as the number of milliseconds >since 1970-jan-01, 00:00 UTC. >UTC leap seconds are ignored.
FYI: https://opengrok.libreoffice.org/xref/core/basic/source/runtime/methods.cxx?r=3ff159d3#2231 https://opengrok.libreoffice.org/xref/core/basic/source/runtime/methods.cxx?r=3ff159d3#2216 https://opengrok.libreoffice.org/xref/core/basic/source/runtime/methods.cxx?r=3ff159d3#4662 >Date aRefDate( 1,1,1900 );
https://api.libreoffice.org/docs/idl/ref/interfacecom_1_1sun_1_1star_1_1i18n_1_1XCalendar.html#a4860d7db902c41f6c4b2a1a0aa77e763 Get the UTC date/time as an offset to the start of the calendar at 1-Jan-1970 00:00. https://help.libreoffice.org/6.4/en-US/text/sbasic/shared/03030101.html?&DbPAR=BASIC&System=WIN
(In reply to himajin100000 from comment #3) > https://api.libreoffice.org/docs/idl/ref/ > interfacecom_1_1sun_1_1star_1_1i18n_1_1XCalendar. > html#a4860d7db902c41f6c4b2a1a0aa77e763 > > Get the UTC date/time as an offset to the start of the calendar at > 1-Jan-1970 00:00. > > https://help.libreoffice.org/6.4/en-US/text/sbasic/shared/03030101. > html?&DbPAR=BASIC&System=WIN I see, it is confusing to use getLocalDateTime and a CDate, the first is using the Unix epoch, the last ones are using the LibreOffice epoch (1900 or 1899). This confusion needs to be avoided. Note: please mark my post as NONBUG