RestKit/RestKit — Issue #455: timestamp with milliseconds, int -> double
Author: payliu
Created: 2011-12-05 02:02:59+00:00
State: open

Dear Sir,

Excuse me,
I got a timestamp, date value is 1322052525.735, should be expected as "2011/11/23 12:48:45.735 +0000" after mapping. but not, it lose 0.735 seconds, "2011/11/23 12:48:45.000 +0000"

so first, I check if NSDate accept a double value. snippet as below. the output is expected.

```objective-c

NSTimeInterval interval = (double)1.322052525735E9;
NSDate* aDate = [NSDate dateWithTimeIntervalSince1970:interval];

NSDateFormatter* df = [[NSDateFormatter alloc] init];
[df setDateFormat:@"yyyy-MM-dd HH:mm:ss.SSS Z"];
[df setTimeZone:[NSTimeZone timeZoneForSecondsFromGMT:0]]; //+0000

NSString* dateStrig = [df stringFromDate:aDate];
NSLog(@"dateString :%@",dateStrig);

``````

```objective-c
output:
dateString :2011-11-23 12:48:45.735 +0000

``````

Then I check [code of Issue#141](https://github.com/RestKit/RestKit/commit/323d5e30b15886493b662c66919d9472a4a639d4) and try to modify RistKit code, just change 'intValue' to 'doubleValue'. it's workable!!!

```objective-c

//code from RKObjectMappingOperation.m

else if ([sourceType isSubclassOfClass:[NSNumber class]] && [destinationType isSubclassOfClass:[NSDate class]]) {
// Number -> Date
//return [NSDate dateWithTimeIntervalSince1970:[(NSNumber*)value intValue]]; //Mark by Pay.
//modify 'value intValue' to 'value of doubleValue', in order to parse milliseconds since 1970.
return [NSDate dateWithTimeIntervalSince1970:[(NSNumber*)value doubleValue]];
}

``````

I wonder whether it's a bug or no. Maybe this modification will impact other thing I don't know.
if possible, please help verify.

I think, before this, use a property to control timestamp will be better for me.

and I have no idea about issue control, to leave message here is right or google groups?! Please forgive me for being impolite.

very thanks!

best regard, Pay.