Reputation: 724
Any reason why I get this error on Mono but not on Windows?
Unhandled Exception: System.FormatException: Invalid format string
at System.DateTime.ParseExact (string,string[],System.IFormatProvider,System.Glo balization.DateTimeStyles) <0x00127>
at System.DateTime.ParseExact (string,string,System.IFormatProvider,System.Globa lization.DateTimeStyles) <0x0004f>
at System.DateTime.ParseExact (string,string,System.IFormatProvider) <0x0001f>
at (wrapper dynamic-method) object.CallSite.Target (System.Runtime.CompilerServi ces.Closure,System.Runtime.CompilerServices.CallSite,System.Type,object,string,S ystem.Globalization.DateTimeFormatInfo) <0x000f3>
at System.Dynamic.UpdateDelegates.UpdateAndExecute4<System.Type, object, string, System.Globalization.DateTimeFormatInfo, object> (System.Runtime.CompilerServic es.CallSite,System.Type,object,string,System.Globalization.DateTimeFormatInfo) < 0x00418>
at TwitterScraper.Program.scrapeTwitter () <0x00a22>
at TwitterScraper.Program.Main (string[]) <0x000bf>
using this code here
DateTime tweettime = DateTime.ParseExact(obj["created_at"].ToString(),
"ddd MMM dd HH:mm:ss %K yyyy",
CultureInfo.InvariantCulture.DateTimeFormat);
This is used to deal with the time format Twitter gives you.
Upvotes: 2
Views: 952
Reputation: 241758
Try this instead:
DateTimeOffset tweettime = DateTimeOffset.ParseExact(yourInputString,
"ddd MMM dd HH:mm:ss zzz yyyy", CultureInfo.InvariantCulture);
Upvotes: 1