Publishing error.

Apr 27, 2009 at 8:51 PM
Hi,

When publishing from Live Writer to Oxite I ge the follwing exception:

The value '20090425T17:09:00' cannot be parsed as the type 'DateTime'.

The line this happens on is here:

case

 

XmlRpcProtocol.DateTime:

 

returnValue =

Convert.ChangeType(reader.ReadElementContentAsDateTime(),targetType);

 


In :

 

public static object Deserialize(XmlDictionaryReader reader, Type targetType)

Any Ideas?

Thanks,

Mike

 

Coordinator
Apr 28, 2009 at 4:58 PM
What culture is your OS set to?  Live Writer must be sending a date that the XmlRpc stuff can't read.  Haven't seen this one before.  :(
Apr 28, 2009 at 7:03 PM
After a bit of fiddeling I can see that the message from Live Writer is sending the dates as follows:

<member>
<name>dateCreated</name>
<value>
<dateTime.iso8601>20090428T18:37:00</dateTime.iso8601>
</value>
</member>
<member>
<name>date_created_gmt</name>
<value>
<dateTime.iso8601>20090428T18:37:00</dateTime.iso8601>
</value>
</member>

As far as I can tell this os ok but DateTime.Parse etc does not take dates like this. The expected format should be allong these lines:

2008-11-01T19:35:00.0000000Z

Coordinator
Apr 28, 2009 at 7:14 PM
Any chance you can try changing your culture or date formatting on your machine to see if Live Writer is picking it up wrong or something?
Apr 28, 2009 at 7:57 PM

A useful article! :

http://blog.stevex.net/index.php/parsing-dates-and-times-in-net/

I have gone for a belts and braces approach in the code:

case XmlRpcProtocol.DateTime:

                       

string dateString = reader.ReadElementContentAsString();

 

string[] formats = new string[] { "r", "s", "u", "yyyyMMddTHHmmss", "yyyyMMddTHH:mm:ss", "yyyy-MM-ddTHH:mm:ss" };

                       

DateTime dt = DateTime.ParseExact(dateString, formats,

   CultureInfo.InvariantCulture, DateTimeStyles.AdjustToUniversal);

 

returnValue = Convert.ChangeType(dt, targetType);

break;

All works for now so I will publish this to my host.

Coordinator
Apr 28, 2009 at 9:36 PM
Cool, glad you got it.  Sampy came to the same conclusion just a few minutes before we saw your post.  We'll make sure this change gets in there for the next release.  Thanks!