A
Adam Clauss
I am trying to parse a date/time string available to me in the format
specified by RFC 2822. I am specifically running into a problem with
the timezone specification. The RFC specifies that the timezone is
specified as a 4 digit offset from UTC, along with a leading + or -.
For example:
-0700
The format string works out roughly to:
ddd, dd MMM yyyy HH:mm:ss zzz
However, the closest usage of the "z" format specifer can get me is
"zzz" => "-07:00" - I believe that the lack of colon in the source data
is throwing it off and causing the ParseExact call to fail. I do not
see an obvious way to create a format string around a 4 digit timezone
specification without a colon.
A specific example that I hit was:
Mon, 22 Mar 2010 03:52:22 -0700
That fails to parse. If I manually in the debugger change it to:
Mon, 22 Mar 2010 03:52:22 -07:00
By inserting the colon, then it works fine.
Trying to parse the string myself to insert a colon feels like a
"hack." Anyone see an easy way out here that I'm missing?
Thanks,
-Adam
specified by RFC 2822. I am specifically running into a problem with
the timezone specification. The RFC specifies that the timezone is
specified as a 4 digit offset from UTC, along with a leading + or -.
For example:
-0700
The format string works out roughly to:
ddd, dd MMM yyyy HH:mm:ss zzz
However, the closest usage of the "z" format specifer can get me is
"zzz" => "-07:00" - I believe that the lack of colon in the source data
is throwing it off and causing the ParseExact call to fail. I do not
see an obvious way to create a format string around a 4 digit timezone
specification without a colon.
A specific example that I hit was:
Mon, 22 Mar 2010 03:52:22 -0700
That fails to parse. If I manually in the debugger change it to:
Mon, 22 Mar 2010 03:52:22 -07:00
By inserting the colon, then it works fine.
Trying to parse the string myself to insert a colon feels like a
"hack." Anyone see an easy way out here that I'm missing?
Thanks,
-Adam