Short Date:
dd/MM/yyyy
dd/MM/yy
d/M/yy
d.M.yy
yyyy-MM-dd
Long Date:
dd MMMM yyyy
d MMMM yyyy
If I use GetDateTimeFormats (d and D) the results match the expected
patterns above, but of course they're the formatted date not the
pattern string.
If I use GetAllDateTimePatterns (d and D) I only get 1 pattern
for both short & long formats.
FWIW, here's an example code snippet:
string [] formats =
System.DateTime.UtcNow.GetDateTimeFormats('d');
formats = System.DateTime.UtcNow.GetDateTimeFormats('D');
formats =
System.DateTime.UtcNow.GetDateTimeFormats(System.Globalization.CultureInfo.CurrentCulture);
System.Globalization.DateTimeFormatInfo dtfi = new
System.Globalization.DateTimeFormatInfo();
formats = dtfi.GetAllDateTimePatterns('d');
formats = dtfi.GetAllDateTimePatterns('D');
... and these are the string arrays returned:
GetDateTimeFormats('d'):
30/12/2009
30/12/09
30/12/09
30.12.09
2009-12-30
GetDateTimeFormats('D'):
30 December 2009
30 December 2009
GetAllDateTimePatterns('d'):
MM/dd/yyyy
GetAllDateTimePatterns('D'):
dddd, dd MMMM yyyy
How do you get the format strings that GetDateTimeFormats uses - they
appear to be what the OS uses, and are not what GetAllDateTimePatterns
returns.
Dave
http://msdn.microsoft.com/en-us/library/aszyst2c.aspx
--
Mihai Nita [Microsoft MVP, Visual C++]
http://www.mihai-nita.net
------------------------------------------
Replace _year_ with _ to get the real email
Hi Mihai,
As I mentioned in my original post, GetAllDateTimePatterns doesn't get
the patterns that the OS shows - which correspond to the ones that
GetDateTimeFormats uses.
Dave