[DllImport("kernel32.dll")]
static extern int GetTimeFormat(uint locale, uint dwFlags, ref SystemTime time, string format, StringBuilder sb, int sbSize);
SYSTEMTIME in Win32 is different then DateTime in CLR. This structure may represent SYSTEMTIME in CLR world:
[StructLayout(LayoutKind.Sequential)]
private struct SystemTime {
[MarshalAs(UnmanagedType.U2)] public ushort Year;
[MarshalAs(UnmanagedType.U2)] public ushort Month;
[MarshalAs(UnmanagedType.U2)] public ushort DayOfWeek;
[MarshalAs(UnmanagedType.U2)] public ushort Day;
[MarshalAs(UnmanagedType.U2)] public ushort Hour;
[MarshalAs(UnmanagedType.U2)] public ushort Minute;
[MarshalAs(UnmanagedType.U2)] public ushort Second;
[MarshalAs(UnmanagedType.U2)] public ushort Milliseconds;
}
Win32 interprets format differently than CLR does so if you don't need exactly Win32 compatible behavior use DateTime.ToString() instead.
Please add some!
(see sample code for GetDateFormat())
DateTime.ToString(string format, IFormatProvider provider);