mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-22 16:33:29 +00:00
MacOS-X compatibility tweaks
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@20913 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
2936dce70f
commit
e02b33b60b
4 changed files with 32 additions and 17 deletions
|
@ -11,6 +11,8 @@
|
|||
* Source/Additions/GSFunctions.m: New file for extra functions.
|
||||
* Source/NSString.m: ([stringByExpandingTildeInPath]) Improve handling
|
||||
of paths containing mingw drives.
|
||||
* Source/NSDate.m: Use same values for distant past/future as MacOSX
|
||||
* Source/NSCalendarDate.m: Support output of extreme year values.
|
||||
|
||||
2005-03-14 Adam Fedor <fedor@gnu.org>
|
||||
|
||||
|
|
|
@ -1742,25 +1742,37 @@ static void Grow(DescriptionInfo *info, unsigned size)
|
|||
ycent = YES;
|
||||
case 'y':
|
||||
v = info->yd;
|
||||
if (v < 0)
|
||||
v = 0;
|
||||
if (v > 9999)
|
||||
v = 9999;
|
||||
if (ycent)
|
||||
{
|
||||
Grow(info, 4);
|
||||
info->t[info->offset+3] = (v%10) + '0';
|
||||
v /= 10;
|
||||
info->t[info->offset+2] = (v%10) + '0';
|
||||
v /= 10;
|
||||
info->t[info->offset+1] = (v%10) + '0';
|
||||
v /= 10;
|
||||
info->t[info->offset+0] = (v%10) + '0';
|
||||
info->offset += 4;
|
||||
if (v >= 0 && v <= 9999)
|
||||
{
|
||||
Grow(info, 4);
|
||||
info->t[info->offset+3] = (v%10) + '0';
|
||||
v /= 10;
|
||||
info->t[info->offset+2] = (v%10) + '0';
|
||||
v /= 10;
|
||||
info->t[info->offset+1] = (v%10) + '0';
|
||||
v /= 10;
|
||||
info->t[info->offset+0] = (v%10) + '0';
|
||||
info->offset += 4;
|
||||
}
|
||||
else
|
||||
{
|
||||
unsigned char tmp[16];
|
||||
int idx = 0;
|
||||
|
||||
sprintf(tmp, "%d", v);
|
||||
Grow(info, strlen(tmp));
|
||||
while (tmp[idx] != '\0')
|
||||
{
|
||||
info->t[info->offset++] = tmp[idx++];
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Grow(info, 2);
|
||||
if (v < 0) v = -v;
|
||||
v = v % 100;
|
||||
info->t[info->offset+1] = (v%10) + '0';
|
||||
v /= 10;
|
||||
|
|
|
@ -50,10 +50,9 @@
|
|||
#include <stdlib.h>
|
||||
#include "GSPrivate.h"
|
||||
|
||||
/* I hope 100,000 years is distant enough. */
|
||||
#define DISTANT_YEARS 100000.0
|
||||
#define DISTANT_FUTURE (DISTANT_YEARS * 365.0 * 24 * 60 * 60)
|
||||
#define DISTANT_PAST (-DISTANT_FUTURE)
|
||||
/* These constants seem to be what MacOS-X uses */
|
||||
#define DISTANT_FUTURE 63113990400.0
|
||||
#define DISTANT_PAST -63113817600.0
|
||||
|
||||
const NSTimeInterval NSTimeIntervalSince1970 = 978307200.0;
|
||||
|
||||
|
|
|
@ -27,6 +27,8 @@ main()
|
|||
|
||||
pool = [[NSAutoreleasePool alloc] init];
|
||||
|
||||
NSLog(@"%@", [NSCalendarDate distantFuture]);
|
||||
NSLog(@"%@", [NSCalendarDate distantPast]);
|
||||
NSLog(@"%@", [NSCalendarDate dateWithNaturalLanguageString: @"01-08-2002 00:00:00"]);
|
||||
NSLog(@"%@", [NSCalendarDate dateWithNaturalLanguageString: @"31-08-2002 23:59:59"]);
|
||||
|
||||
|
|
Loading…
Reference in a new issue