Bug 133711 - getLocalDateTime function shows the wrong date
Summary: getLocalDateTime function shows the wrong date
Status: RESOLVED NOTABUG
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: sdk (show other bugs)
Version:
(earliest affected)
7.0.0.0.alpha1+
Hardware: x86-64 (AMD64) Windows (All)
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords: skillCpp
Depends on:
Blocks: Macro-UNOAPI Macro-Documentation
  Show dependency treegraph
 
Reported: 2020-06-05 19:06 UTC by libre officer
Modified: 2020-06-11 12:33 UTC (History)
1 user (show)

See Also:
Crash report or crash signature:
Regression By:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description libre officer 2020-06-05 19:06:50 UTC
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.
Comment 4 libre officer 2020-06-11 11:47:21 UTC
(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