mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-22 16:33:29 +00:00
on 32bit systems constrain dates to fit
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@39549 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
a2ed652ca2
commit
1db866fde7
4 changed files with 40 additions and 4 deletions
|
@ -63,6 +63,9 @@
|
|||
@end
|
||||
|
||||
|
||||
#define DISTANT_FUTURE 63113990400.0
|
||||
#define DISTANT_PAST -63113817600.0
|
||||
|
||||
static NSString *cformat = @"%Y-%m-%d %H:%M:%S %z";
|
||||
|
||||
static NSTimeZone *localTZ = nil;
|
||||
|
@ -1620,6 +1623,16 @@ static inline int getDigits(const char *from, char *to, int limit, BOOL *error)
|
|||
format: @"[%@-%@] interval is not a number",
|
||||
NSStringFromClass([self class]), NSStringFromSelector(_cmd)];
|
||||
}
|
||||
#if GS_SIZEOF_VOIDP == 4
|
||||
if (seconds <= DISTANT_PAST)
|
||||
{
|
||||
seconds = DISTANT_PAST;
|
||||
}
|
||||
else if (seconds >= DISTANT_FUTURE)
|
||||
{
|
||||
seconds = DISTANT_FUTURE;
|
||||
}
|
||||
#endif
|
||||
_seconds_since_ref = seconds;
|
||||
if (_calendar_format == nil)
|
||||
{
|
||||
|
|
|
@ -1412,6 +1412,18 @@ otherTime(NSDate* other)
|
|||
format: @"[%@-%@] interval is not a number",
|
||||
NSStringFromClass([self class]), NSStringFromSelector(_cmd)];
|
||||
}
|
||||
|
||||
#if GS_SIZEOF_VOIDP == 4
|
||||
if (secs <= DISTANT_PAST)
|
||||
{
|
||||
secs = DISTANT_PAST;
|
||||
}
|
||||
else if (secs >= DISTANT_FUTURE)
|
||||
{
|
||||
secs = DISTANT_FUTURE;
|
||||
}
|
||||
#endif
|
||||
|
||||
_seconds_since_ref = secs;
|
||||
return self;
|
||||
}
|
||||
|
|
|
@ -37,12 +37,22 @@ int main(void)
|
|||
{
|
||||
CREATE_AUTORELEASE_POOL(arp);
|
||||
|
||||
PASS_EQUAL(formattedDaysSince1970(8640000000), @"17-07-23657486",
|
||||
"format date for 8640000000");
|
||||
if (sizeof(NSInteger) == 4)
|
||||
{
|
||||
PASS_EQUAL(formattedDaysSince1970(8640000000), @"02-01-4001",
|
||||
"format date for 8640000000");
|
||||
|
||||
PASS_EQUAL(formattedDaysSince1970(2147483651), @"15-07-5881580",
|
||||
"format date for 2147483651");
|
||||
PASS_EQUAL(formattedDaysSince1970(2147483651), @"02-01-4001",
|
||||
"format date for 2147483651");
|
||||
}
|
||||
else
|
||||
{
|
||||
PASS_EQUAL(formattedDaysSince1970(8640000000), @"17-07-23657486",
|
||||
"format date for 8640000000");
|
||||
|
||||
PASS_EQUAL(formattedDaysSince1970(2147483651), @"15-07-5881580",
|
||||
"format date for 2147483651");
|
||||
}
|
||||
DESTROY(arp);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -46,6 +46,7 @@ int main()
|
|||
NSEnumerator *e = [a objectEnumerator];
|
||||
NSString *s = nil;
|
||||
|
||||
NSLog(@"Got %@", a);
|
||||
while ((s = [e nextObject]) != nil)
|
||||
if ([s rangeOfString: @"testAbc"].length > 0)
|
||||
break;
|
||||
|
|
Loading…
Reference in a new issue