Is it normal that TFormatSettings.Create('en-US')
returns with ShortDateFormat = 'm/d/yy'
on Android but returns with ShortDateFormat = 'M/d/yyyy'
on Windows ? Is it a bug? I was thinking that the settings must be consistent against platforms.
TFormatSetting
uses platform-specific settings whenever possible, even when using the same locale across platforms.
On all platforms, TFormatSettings.Create(LocaleName)
converts the LocalName
to a platform-specific TLocaleID
and then calls TFormatSettings.Create(LocaleID)
.
On Windows, the LocaleName
is converted to a TLocaleID
(alas for LCID
) via LocaleNameToLCID()
on Vista and later, and EnumSystemLocales()
on earlier versions. The LCID
for 'en-US'
is 1033. 'm/d/yy'
is the RTL's default if the Win32 API GetLocaleInfo()
function does not return a LOCALE_SSHORTDATE
string for the specified LocaleID
. On your system, Windows is returning 'M/d/yyyy'
for LCID 1033, so the RTL's default is not used.
On Android, the underlying localization library used by the RTL is the cross-platform ICU library, so the LocalName
is converted to a TLocaleID
by simply encoding it as UTF-8 and then using that as-is. 'm/d/y'
is the RTL's default if ICU does not return a UDAT_SHORT
string for the specified LocaleID
. On your system, ICU is returning 'm/d/yy'
for 'en-US'
, so the RTL's default is not used.