I can convert a Delphi TDate to ISO 8601 format easily using this:
DateTimeToString(result, \'yyyy-mm-dd\', myDate);
What\'s the idiomatic
I think this should work... the documentation says the overloaded version of these methods is for use in threads, but it can be handy for specifying the format settings you wish to use at the time.
Function ISO8601ToDateTime(Value: String):TDateTime;
var
FormatSettings: TFormatSettings;
begin
GetLocaleFormatSettings(GetThreadLocale, FormatSettings);
FormatSettings.DateSeparator := '-';
FormatSettings.ShortDateFormat := 'yyyy-MM-dd';
Result := StrToDate(Value, FormatSettings);
end;
You can of course write variants of this with StrToDateDef and TryStrToDate with equivalent functionality