DateTime fields are 'nil' on IOS4

Aug 25, 2010 at 5:56 PM

Has anyone else had this problem? Connecting IOS4.0.2 SDK to OData DataService, all DateTime fields a 'nil'

Data looks like this:

    <d:DateReceived m:type="Edm.DateTime">2010-04-01T16:28:06.97</d:DateReceived>

 

It would appear that the IOS4 NSDateFormatter is a lot more picky.  And it doesn't like the milliseconds on the end of the time. I got it working by changing ODataRTTI.m(112) from

[dateFormat setDateFormat:@"yyyy-MM-dd'T'HH:mm:ss"];

to

[dateFormat setDateFormat:@"yyyy-MM-dd'T'HH:mm:ss.SS"];

 

 

 

 

Aug 25, 2010 at 6:22 PM

This seems to be a bug in the code. I had a discussion with the dev team about DateTime formatting in the code, I asked them to make sure the lib can handle the format specified in the OData spec: 'yyyy-mm-ddThh:mm[:ss[.fffffff]]'

I'll follow up with the dev team and make sure this is fixed in the next release of the code.

Thanks

CLaudio

 

Sep 21, 2010 at 11:37 AM
Edited Sep 23, 2010 at 12:27 PM

v1.1 still doesn't work! The line of code has changed to:

[dateFormat setDateFormat:@"yyyy-MM-dd'T'HH:mm:ss'Z'"];

which still doesn't cope with milliseconds! I have regenerated the proxy classes. Am I missing something? Going to try 4.1SDK.

 

Update: Gave up, and changed my SQL Server Database field type to 'smalldatetime' from 'datetime', so there are no milliseconds stored. Surprised no-one else has had this problem!

Oct 13, 2010 at 9:56 PM

It seems the wrong fix for this problem. I'll follow up with the dev team again and make sure we find a solution that works for both OData protocol spec for DateTime and iOS date/Time APIs.

Claudio

 

 

 

Mar 19, 2011 at 8:43 PM

Any update on this issue?  I am using the v1.1 release with iOS 4.2.1 on the ipod and 4.3 in the simulator.  All of my dates are coming out nil.  Changing the SQL Server Datebase field type to 'smalldatetime' from 'datetime' like stickybunn mentions above fixed the problem for me.