I’m trying to create a header for a column of dates that correctly shows the format of the date in the locale in which the computer is working, e.g.'s d/m/y, m/d/y, y/m/d etc
The following gets part of the way there:
[code]//first get the appropriate translated abbreviations for d/m/y in this language
Dim ss() As String = Split(lingo.Y_M_D, “/”)
//use the current local shortdate to determine the order and translation of the d/m/y string
Dim d As New DateTime(2000, 12, 30)
Dim s As String = d.ToString(Nil, datetime.FormatStyles.Short, dateTime.FormatStyles.none)
//s will be a d/m/y string in the local format - not dependent on the language of the app.
If s.IndexOf(“2000”) <> -1 Then
s = ReplaceAll(s, “2000”, Trim(ss(0)))
Elseif s.IndexOf(“00”) <> -1 Then
s = ReplaceAll(s, “00”, Trim(ss(0)))
If s.IndexOf(“12”) <> -1 Then
s = ReplaceAll(s, “12”, Trim(ss(1)))
If s.IndexOf(“30”) <> -1 Then
s = ReplaceAll(s, “30”, Trim(ss(2)))
But it doesn’t work for non-Gregorian calendars e.g. Arabic for which the date created by the new DateTime would be different. For example, 2000/12/30 in Saudi comes out as 04/10/1421 AH, whilst in Afghanistan it becomes 10/10/1379 AP - there are probably others too.
Whilst only a small part of the potential market - is there a way to get this right?