Make more tolerant of missing zone when parsing string ... not strictly

MacOS-X compatible, but nicer.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@16315 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-Macdonald 2003-04-01 14:32:41 +00:00
parent 14778174bf
commit 8bbf670347
2 changed files with 14 additions and 5 deletions

View file

@ -3,6 +3,7 @@
* Source/NSCalendarDate.m: ([initWithString:calendarFormat:locale:])
add support for %F millisecond initialisation.
make trivial simplification of timezone handling.
on failure to parse zone using %z, use local time zone.
2003-03-31 Stephane Corthesy <stephane@sente.ch>

View file

@ -1032,6 +1032,7 @@ static inline int getDigits(const char *from, char *to, int limit)
{
int sign = 1;
int zone;
int found;
if (source[sourceIdx] == '+')
{
@ -1042,11 +1043,18 @@ static inline int getDigits(const char *from, char *to, int limit)
sign = -1;
sourceIdx++;
}
sourceIdx += getDigits(&source[sourceIdx], tmpStr, 4);
zone = atoi(tmpStr) * sign;
tz = [NSTimeZone timeZoneForSecondsFromGMT:
(zone / 100 * 60 + (zone % 100)) * 60];
found += getDigits(&source[sourceIdx], tmpStr, 4);
if (found > 0)
{
sourceIdx += found;
if (found == 2)
{
zone *= 100; // Convert 2 digits to 4
}
zone = atoi(tmpStr);
tz = [NSTimeZone timeZoneForSecondsFromGMT:
sign * ((zone / 100) * 60 + (zone % 100)) * 60];
}
}
break;