Mon 24 Apr 2006 04:31:38 AM UTC, original submission:
There is a bug #14863 with suggesting:
----------------------------------------------------------------------------------------------
I think the milliseconds are accidentally getting truncated at line 1868 of the current CVS file (1.110) with the statement:
v = (int)s;
I believe the correct line is
v = (int) (s * 1000);
----------------------------------------------------------------------------------------------
But variable "s" has type "double". So "1000" also cast to that type. Here is an error which can see in the followed testcase:
----------------------------------------------------------------------------------------------
NSString *fmt = [NSString
stringWithFormat:@"%%Y-%%m-%%d %%H:%%M:%%S:%%F"];
NSString *dateString = [NSString
stringWithFormat:@"2006-4-22 22:22:22:901"];
NSCalendarDate *date = [NSCalendarDate
dateWithString:dateString calendarFormat:fmt];
NSLog(@"format %@", fmt);
NSLog(@"input date %@", dateString);
NSLog(@"output date %@", [date descriptionWithCalendarFormat:fmt]);
----------------------------------------------------------------------------------------------
With results:
----------------------------------------------------------------------------------------------
2006-04-24 04:15:42.923 nscalday[12266] format %Y-%m-%d %H:%M:%S:%F
2006-04-24 04:15:42.932 nscalday[12266] input date 2006-4-22 22:22:22:901
2006-04-24 04:15:42.932 nscalday[12266] output date 2006-04-22 22:22:22:900
----------------------------------------------------------------------------------------------
900 milliseconds but must be 901.
So the line (1868) could be looked:
v = (int) (s * 10000 / 10);
or
v = (int) round(s * 1000);
|