public static class Extensions
{
public static DateTime ParseTwitterTime(this string date)
{
const string format = "ddd, dd MMM yyyy HH:mm:ss zzzz";
return DateTime.ParseExact(date, format, CultureInfo.InvariantCulture);
}
}
What i does is takes the string from the XML response formatted like this "Wed, 08 Apr 2009 19:22:10 +0000" and parses it as an DateTime. Having it as an extension allows me to use in inside LINQ queries.
(And I needed something to test the SyntaxHighlighter script)
Updated 2010-09-06: Twitter changed it's format in the api
A small but 'real' post. Twitter stores all dates in a well, nonstandard way, so i came up with the following extension for my project to handle this: