[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug #16426] NSCalendarDate don't work properly with milliseconds
From: |
Sergey Golovin |
Subject: |
[bug #16426] NSCalendarDate don't work properly with milliseconds |
Date: |
Mon, 24 Apr 2006 04:31:39 +0000 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8b4) Gecko/20051004 Firefox 1.4 |
URL:
<http://savannah.gnu.org/bugs/?func=detailitem&item_id=16426>
Summary: NSCalendarDate don't work properly with
milliseconds
Project: GNUstep
Submitted by: svg
Submitted on: Понедельник 24.04.2006 at 04:31
Category: Base/Foundation
Severity: 3 - Normal
Item Group: Bug
Status: None
Privacy: Public
Assigned to: None
Open/Closed: Open
_______________________________________________________
Details:
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);
_______________________________________________________
Reply to this item at:
<http://savannah.gnu.org/bugs/?func=detailitem&item_id=16426>
_______________________________________________
Message sent via/by Savannah
http://savannah.gnu.org/
- [bug #16426] NSCalendarDate don't work properly with milliseconds,
Sergey Golovin <=