bugGNUstep - Bugs: bug #16426, NSCalendarDate don't work properly...

 
 

You are not allowed to post comments on this tracker with your current authentification level.

bug #16426: NSCalendarDate don't work properly with milliseconds

Submitted by:  Sergei Golovin <svg>
Submitted on:  Mon 24 Apr 2006 04:31:38 AM UTC  
 
Category: Base/FoundationSeverity: 3 - Normal
Item Group: BugStatus: Fixed
Privacy: PublicAssigned to: None
Open/Closed: Closed

Wed 26 Apr 2006 01:36:56 PM UTC, comment #1:

The actual bug was a floaring point rounding error ... in your test case the .901 of a second value was stored as .90099999

This is now fixed in SVN to round to the nearest millisecond (with a half millisecond rounding up).

Richard Frith-Macdonald <CaS>
Project Member
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);

Sergei Golovin <svg>

 

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

CC list is empty

 

Do you think this task is very important?
If so, you can click here to add your encouragement to it.
This task has 0 encouragements so far.

Only logged-in users can vote.

 

Please enter the title of George Orwell's famous dystopian book (it's a date):

 

 

Follow 2 latest changes.

Date Changed By Updated Field Previous Value => Replaced By
Wed 26 Apr 2006 01:36:56 PM UTCCaSStatusNone=>Fixed
  Open/ClosedOpen=>Closed

Back to the top


Powered by Savane 3.1-cleanup