mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-23 00:41:02 +00:00
fix for displaying timestamp milliseconds by Larry Campbell
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@37683 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
b59e270241
commit
1316bf3a0f
2 changed files with 12 additions and 12 deletions
|
@ -1,3 +1,7 @@
|
|||
2014-02-13 Larry Campbell <lcampbel@akamai.com>
|
||||
|
||||
* Source/NSCalendarDate.m: Fixup millisecond formatting to match OSX
|
||||
|
||||
2014-02-12 Quentin Mathe <quentin.mathe@gmail.com>
|
||||
|
||||
* Tools/gsdoc-1_0_4.dtd: Added new DTD version that declares 'package'
|
||||
|
|
|
@ -252,6 +252,11 @@ GSBreakTime(NSTimeInterval when, int *year, int *month, int *day,
|
|||
int h, m, dayOfEra;
|
||||
double a, b, c, d;
|
||||
|
||||
/* The 0.1 constant was experimentally derived to cause our behavior
|
||||
* to match Mac OS X 10.9.1.
|
||||
*/
|
||||
when = floor(when * 1000.0 + 0.1) / 1000.0;
|
||||
|
||||
// Get reference date in terms of days
|
||||
a = when / 86400.0;
|
||||
// Offset by Gregorian reference
|
||||
|
@ -265,7 +270,7 @@ GSBreakTime(NSTimeInterval when, int *year, int *month, int *day,
|
|||
// Calculate hour, minute, and seconds
|
||||
d = dayOfEra - GREGORIAN_REFERENCE;
|
||||
d *= 86400;
|
||||
a = abs(d - when);
|
||||
a = fabs(d - when);
|
||||
b = a / 3600;
|
||||
*hour = (NSInteger)b;
|
||||
h = *hour;
|
||||
|
@ -277,7 +282,7 @@ GSBreakTime(NSTimeInterval when, int *year, int *month, int *day,
|
|||
m = m * 60;
|
||||
c = a - h - m;
|
||||
*second = (NSInteger)c;
|
||||
*mil = (NSInteger)((a - h - m - c) * 1000.0);
|
||||
*mil = (NSInteger)rint((a - h - m - *second) * 1000.0);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2093,16 +2098,7 @@ static void outputValueWithFormat(int v, char *fldfmt, DescriptionInfo *info)
|
|||
break;
|
||||
|
||||
case 'F': // milliseconds
|
||||
{
|
||||
double s;
|
||||
|
||||
s = ([self dayOfCommonEra] - GREGORIAN_REFERENCE) * 86400.0;
|
||||
s -= (_seconds_since_ref + offset(_time_zone, self));
|
||||
s = fabs(s);
|
||||
s -= floor(s);
|
||||
s *= 1000.0;
|
||||
v = (NSInteger)(s + 0.5);
|
||||
}
|
||||
v = info->mil;
|
||||
if (fmtlen == 1) // no format width specified; supply default
|
||||
{
|
||||
fldfmt[fmtlen++] = '0';
|
||||
|
|
Loading…
Reference in a new issue