Xojo.Core.Date.FormatStyles problem

I can’t get this to return a 4 digit year even when System settings are dd/mm/yyyy
Using d.shortdate is buggy on some European systems so I’ve been using this to convert a date (d) to a shortdate string.

Using xojo.core
Return DateToStringBase(d, Date.FormatStyles.short, Date.FormatStyles.None)
    Private Function DateToStringBase(d as Date, dateFormat as Xojo.Core.Date.FormatStyles, timeFormat as Xojo.Core.Date.FormatStyles) as String
  Using xojo.core
    Dim noTimeZone As New timezone(0)
    Dim d2 As New Date(d.TotalSeconds - 2082844800, noTimeZone)
    Return d2.ToText(Locale.Current, dateFormat, timeFormat)
End Function

always returns dd/mm/yy which is not suitable for old dates where the system confuses the century.

Maybe you can use DateTime.SQLDate,it returns a date in this format: YYYY-MM-DD

Thanks but this function takes a date from a database which is stored in SQL format then converts it to a date and displays it in the user’s system Short Date format.

I’ve noticed this problem has appeared before in this forum unresolved: