ShineOn has a function to do just that:
ConvertDelphiDateTimeFormat(const aFormat: DelphiString): DelphiString;
It also has the inverse:
ConvertClrDateTimeFormat(const aFormat: DelphiString): DelphiString;
It's found in the "Date Functions (SysUtils).pas" file.
The code does indicate it's not 100%
Conversions between date formats:
This is close, but there are some cases where the mapping must be approximate.
For Delphi formats, this means
- am/pm maps to ampm (that is, must use
system setting)
- a/p is based on current settings, not hardcoded to 'a' or 'p'
- no control over case in the am/pm or a/p strings
- no options for how to represent era, they all map to gg
- no support for z -- it maps to fractional seconds with 3 decimals (zzz)
For CLR formats, this means
- no support for single-digit years, they map to 2 digit years.
- no support for 12-hour clock when there is no am/pm symbol, 24-hour is used.
- no support for fractional seconds, they map to milliseconds (zzz)
- no support for time zone offsets