Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2008-03

Date and Time formatting via locale settings doesn't work under FPC 2.2.0

4 messages · 3 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Graeme Geldenhuys

Hi,

Reading the documentation about DateToStr() and DateTimeToStr(), it mentions that it takes the locale and regional settings in consideration when formatting the date and time. I have a Linux PC that used the USA Linux PC that has South Africa
as location (also specified in the installation setup). I also asked a fellow Russian developer to test on his PC.

We used the following line as mentioned in the docs.

  Writeln(Format ('Today is: %s',[DateToStr(Date)]));

Output under Windows (russian):
Today is: 10.03.2008

Under Windows the formatting seems to work fine under all three PC's tested. Date formats changed accordingly.

Output under Linux:
Today is: 10-3-08

We got the exact same output on all three PC's tested. So basically the locale/region information is totally ignored! Is the date format hard-coded under Linux or is there something vital that we are missing under Linux?

Formats as far as I know should have been:
Russia: dd.mm.yyyy
USA: mm-dd-yyyy (I think)
RSA: dd/mm/yyyy or yyyy/mm/dd (dependent on the OS used)

Regards,
- Graeme -

_______________________________________________
fpGUI - a cross-platform Free Pascal GUI toolkit
http://opensoft.homeip.net/fpgui/

Reply by email

Michael Van Canneyt
to Graeme Geldenhuys
Graeme Geldenhuys wrote 27 lines
Hi, Reading the documentation about DateToStr() and DateTimeToStr(), it mentions that it takes the locale and regional settings in consideration when formatting the date and time. I have a Linux PC that used the USA Linux PC that has South Africa as location (also specified in the installation setup). I also asked a fellow Russian developer to test on his PC. We used the following line as mentioned in the docs. Writeln(Format ('Today is: %s',[DateToStr(Date)])); Output under Windows (russian): Today is: 10.03.2008 Under Windows the formatting seems to work fine under all three PC's tested. Date formats changed accordingly. Output under Linux: Today is: 10-3-08 We got the exact same output on all three PC's tested. So basically the locale/region information is totally ignored! Is the date format hard-coded under Linux or is there something vital that we are missing under Linux?

The locale/region information is ignored by default. I have a unit that loads this information using Libc or the KDE settings, but it is not an option to have this in sysutils by default, since it introduces a dependency on Libc.

The section on 'Localization support' in the sysutils documentation mentions that:

Localization support depends on various constants and structures being initialized correctly. On Windows and OS/2 this is done automatically: a widestring manager is installed by default which helps taking care of the current locale when performing various operations on strings. The various internationalization settings (date/time format, currency, language etc) are also initialized correctly on these platforms.

Michael.

Reply by email

Graeme Geldenhuys
to Michael Van Canneyt
Michael Van Canneyt wrote 5 lines
The locale/region information is ignored by default. I have a unit that loads this information using Libc or the KDE settings, but it is not an option to have this in sysutils by default, since it introduces a dependency on Libc.

Thanks Michael. We had an alternative in case FPC hard-coded it. :-) We will use the language translation files to set default (preferred) date/time formats. All other languages will default to the ISO 8601 format.

Summary of ISO 8601 http://www.cl.cam.ac.uk/~mgk25/iso-time.html

Constant definitions would look like the following:
  'yyyymmdd"T"hhmmss';    // for storage
  'yyyy-mm-dd hh:mm:ss';  // for display

Regards,
- Graeme -

_______________________________________________
fpGUI - a cross-platform Free Pascal GUI toolkit
http://opensoft.homeip.net/fpgui/

Reply by email

Tomas Hajny
to Michael Van Canneyt: The locale/region information is ignored by default. I have a unit that loads this…
Michael Van Canneyt wrote
On Mon, 10 Mar 2008, Graeme Geldenhuys wrote:

.
.

Show quoted text 11 lines
The section on 'Localization support' in the sysutils documentation mentions that: Localization support depends on various constants and structures being initialized correctly. On Windows and OS/2 this is done automatically: a widestring manager is installed by default which helps taking care of the current locale when performing various operations on strings. The various internationalization settings (date/time format, currency, language etc) are also initialized correctly on these platforms.

Actually, I believe the widestring manager routines are still dummy for OS/2, i.e. not implemented yet. I don't remember about the other internationalization stuff right now from the top of my head.

Tomas

Reply by email