I am getting some junk data returned from a ToString() call on a DateTime object in C# and I'm afraid I'm stumped after poking around with it for a while.
The function is supposed to format dates to be compliant with RFC 822 (as required by the RSS spec) and looks like:
public static string FormatPubDate(DateTime pubDate)
{
string _rfc822Format = "ddd, dd MMM yyyy HH:mm:ss";
string _tmp = pubDate.ToUniversalTime().ToString(_rfc822Format);
return pubDate.ToString(_tmp + " UT");
}
Which should be what I want, from what I can read of the DateTime ToString() docs.
However, for some dates it's generating junk:
Console.WriteLine(FormatPubDate(new DateTime(2008, 12, 16, 13, 44, 33)));
Console.WriteLine(FormatPubDate(new DateTime(2008, 12, 17, 13, 44, 33)));
Console.WriteLine(FormatPubDate(new DateTime(2009, 3, 18, 4, 17, 20)));
Console.WriteLine(FormatPubDate(new DateTime(2009, 4, 30, 10, 44, 33)));
Yields:
Tue, 16 Dec 2008 19:44:33 UT
We17, 17 Dec 2008 19:44:33 UT
We18, 18 3ar 2009 09:17:20 UT
T10u, 30 Apr 2009 15:44:33 UT
Any ideas why it's returning We18 instead of Wed and 3ar instead of Mar?