Date format within the application

Lazarus like any other programming language takes some information from the operating system, for example when using:

mydate:=DateToStr('01/01/1970');

This will work fine on Windows, but it may fail in some graphical environments on Linux. This happens because the installed Windows is already localized in the Portuguese environment and is always the same in any edition, but in Linux the localization and translation, even if in Portuguese, the date format may be different.

This occurs for example in GNOME version 41

One way to solve this problem is to include the instructions below in the unit that initialized your program, right in the section initialization(maybe you have to create it)

initialization DefaultFormatSettings.DateSeparator:='/'; DefaultFormatSettings.ShortDateFormat:='DD/MM/YYYY'; DefaultFormatSettings.LongDateFormat:='dd" "mmmm" "yyyy'; DefaultFormatSettings.CurrencyString:='R$'; DefaultFormatSettings.DecimalSeparator:=','; // Abbreviated month names DefaultFormatSettings.ShortMonthNames[1] := 'Jan'; DefaultFormatSettings.ShortMonthNames[2] := 'Feb'; DefaultFormatSettings.ShortMonthNames[3] := 'Mar'; DefaultFormatSettings.ShortMonthNames[4] := 'Abr'; DefaultFormatSettings.ShortMonthNames[5] := 'May'; DefaultFormatSettings.ShortMonthNames[6] := 'Jun'; DefaultFormatSettings.ShortMonthNames[7] := 'Jul'; DefaultFormatSettings.ShortMonthNames[8] := 'Aug'; DefaultFormatSettings.ShortMonthNames[9] := 'Set'; DefaultFormatSettings.ShortMonthNames[10] := 'Out'; DefaultFormatSettings.ShortMonthNames[11] := 'Nov'; DefaultFormatSettings.ShortMonthNames[12] := 'Ten'; // Month name DefaultFormatSettings.LongMonthNames[1] := 'January'; DefaultFormatSettings.LongMonthNames[2] := 'February'; DefaultFormatSettings.LongMonthNames[3] := 'March'; DefaultFormatSettings.LongMonthNames[4] := 'April'; DefaultFormatSettings.LongMonthNames[5] := 'May'; DefaultFormatSettings.LongMonthNames[6] := 'June'; DefaultFormatSettings.LongMonthNames[7] := 'July'; DefaultFormatSettings.LongMonthNames[8] := 'August'; DefaultFormatSettings.LongMonthNames[9] := 'September'; DefaultFormatSettings.LongMonthNames[10] := 'October'; DefaultFormatSettings.LongMonthNames[11] := 'November'; DefaultFormatSettings.LongMonthNames[12] := 'December'; // Name of the abbreviated days of the week DefaultFormatSettings.ShortDayNames[1] := 'Dom'; DefaultFormatSettings.ShortDayNames[2] := 'Mon'; DefaultFormatSettings.ShortDayNames[3] := 'Have'; DefaultFormatSettings.ShortDayNames[4] := 'Wed'; DefaultFormatSettings.ShortDayNames[5] := 'Thu'; DefaultFormatSettings.ShortDayNames[6] := 'Sex'; DefaultFormatSettings.ShortDayNames[7] := 'Sat'; // Name of days of the week DefaultFormatSettings.LongDayNames[1] := 'Sunday'; DefaultFormatSettings.LongDayNames[2] := 'Monday'; DefaultFormatSettings.LongDayNames[3] := 'Tuesday'; DefaultFormatSettings.LongDayNames[4] := 'Wednesday'; DefaultFormatSettings.LongDayNames[5] := 'Thursday'; DefaultFormatSettings.LongDayNames[6] := 'Friday'; DefaultFormatSettings.LongDayNames[7] := 'Saturday';

If your program will be internationalized, I recommend creating a form where the above variables can be modified according to the location where the program will be executed.

The other way is to know the graphic environment correctly and adjust it to use date and time in Brazilian format.