git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@28255 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
rfm 2009-04-27 18:04:56 +00:00
parent 9f65255a15
commit b29b9a4f76
2 changed files with 20 additions and 14 deletions

View file

@ -1,3 +1,7 @@
2009-04-27 Richard Frith-Macdonald <rfm@gnu.org>
* Source/NSCalendarDate.m: Fix bug #26360 plus optimise a little.
2009-04-27 Richard Frith-Macdonald <rfm@gnu.org> 2009-04-27 Richard Frith-Macdonald <rfm@gnu.org>
* Headers/Foundation/NSData.h: * Headers/Foundation/NSData.h:

View file

@ -70,6 +70,7 @@ static NSString *cformat = @"%Y-%m-%d %H:%M:%S %z";
static NSTimeZone *localTZ = nil; static NSTimeZone *localTZ = nil;
static Class NSCalendarDateClass;
static Class absClass; static Class absClass;
static Class dstClass; static Class dstClass;
@ -321,6 +322,7 @@ GSTimeNow(void)
{ {
if (self == [NSCalendarDate class]) if (self == [NSCalendarDate class])
{ {
NSCalendarDateClass = self;
[self setVersion: 1]; [self setVersion: 1];
localTZ = RETAIN([NSTimeZone localTimeZone]); localTZ = RETAIN([NSTimeZone localTimeZone]);
@ -1295,7 +1297,7 @@ static inline int getDigits(const char *from, char *to, int limit, BOOL *error)
if ((had & (hadY|hadw)) != (hadY|hadw)) if ((had & (hadY|hadw)) != (hadY|hadw))
{ {
NSCalendarDate *now = [[NSCalendarDate alloc] init]; NSCalendarDate *now = [[NSCalendarDateClass alloc] init];
[now setTimeZone: gmtZone]; [now setTimeZone: gmtZone];
if ((had & hadY) == 0) if ((had & hadY) == 0)
@ -1311,13 +1313,13 @@ static inline int getDigits(const char *from, char *to, int limit, BOOL *error)
RELEASE(now); RELEASE(now);
} }
d = [[NSCalendarDate alloc] initWithYear: year d = [[NSCalendarDateClass alloc] initWithYear: year
month: 1 month: 1
day: 1 day: 1
hour: 0 hour: 0
minute: 0 minute: 0
second: 0 second: 0
timeZone: gmtZone]; timeZone: gmtZone];
currDay = [d dayOfWeek]; currDay = [d dayOfWeek];
RELEASE(d); RELEASE(d);
@ -1347,7 +1349,7 @@ static inline int getDigits(const char *from, char *to, int limit, BOOL *error)
*/ */
if ((had & hadY) == 0) if ((had & hadY) == 0)
{ {
NSCalendarDate *now = [[NSCalendarDate alloc] init]; NSCalendarDate *now = [[NSCalendarDateClass alloc] init];
year = [now yearOfCommonEra]; year = [now yearOfCommonEra];
RELEASE(now); RELEASE(now);
@ -2568,9 +2570,9 @@ static void Grow(DescriptionInfo *info, unsigned size)
*/ */
s = GSTime(day, month, year, hour, minute, second, mil); s = GSTime(day, month, year, hour, minute, second, mil);
s -= oldOffset; s -= oldOffset;
c = [NSCalendarDate alloc]; c = [NSCalendarDateClass alloc];
c->_calendar_format = cformat; c->_calendar_format = [_calendar_format copy];
c->_time_zone = RETAIN([self timeZone]); c->_time_zone = [_time_zone copy];
c->_seconds_since_ref = s; c->_seconds_since_ref = s;
/* /*
@ -2631,13 +2633,13 @@ static void Grow(DescriptionInfo *info, unsigned size)
/* FIXME What if the two dates are in different time zones? /* FIXME What if the two dates are in different time zones?
How about daylight savings time? How about daylight savings time?
*/ */
if ([date isKindOfClass: [NSCalendarDate class]]) if ([date isKindOfClass: NSCalendarDateClass])
{ {
tmp = (NSCalendarDate*)RETAIN(date); tmp = (NSCalendarDate*)RETAIN(date);
} }
else if ([date isKindOfClass: [NSDate class]]) else if ([date isKindOfClass: [NSDate class]])
{ {
tmp = [[NSCalendarDate alloc] initWithTimeIntervalSinceReferenceDate: tmp = [[NSCalendarDateClass alloc] initWithTimeIntervalSinceReferenceDate:
[date timeIntervalSinceReferenceDate]]; [date timeIntervalSinceReferenceDate]];
} }
else else