.net - How do I parse date strings with time zones like 'G8T' and 'G12T'? -


in asp.net application, need check modified date when retrieving images remote server. header values "last-modified" strings following:

  • thu, 08 dec 2011 19:57:12 g12t
  • thu, 14 aug 2003 16:13:20 g8t

.net's datetime.parse() method fails on these formatexception ("the string not recognized valid datetime. there unknown word starting @ index 26."). there options can pass make a(ny) parsing method recognize time zone indicators? have not seen them before, , a google search turns apparent usages on forums , similar sites, no helpful information mean.

(oddly, header values "date" on same images end "gmt". remote server iis 7.5.)

i can't check right now, might work:

datetimeoffset result = datetimeoffset.parseexact(text,     "ddd, dd mmm yyyy hh:mm:ss 'g'z't'",     cultureinfo.invariantculture); 

that's using z custom specifier... format sign, may not require 1 when parsing.

if you're happy use bleeding-edge code, believe noda time 1.2 (unreleased) should able cope using offsetdatetimepattern of ddd, dd mmm yyyy hh:mm:ss 'g'o<-h>'t'. again, can't test right i'd expect work. mean running currently-unreleased code though...


Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -