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:
CaS 2003-04-01 14:32:41 +00:00
parent 45044f458e
commit c77a751c49
2 changed files with 14 additions and 5 deletions

View file

@ -3,6 +3,7 @@
* Source/NSCalendarDate.m: ([initWithString:calendarFormat:locale:]) * Source/NSCalendarDate.m: ([initWithString:calendarFormat:locale:])
add support for %F millisecond initialisation. add support for %F millisecond initialisation.
make trivial simplification of timezone handling. 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> 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 sign = 1;
int zone; int zone;
int found;
if (source[sourceIdx] == '+') if (source[sourceIdx] == '+')
{ {
@ -1042,11 +1043,18 @@ static inline int getDigits(const char *from, char *to, int limit)
sign = -1; sign = -1;
sourceIdx++; sourceIdx++;
} }
sourceIdx += getDigits(&source[sourceIdx], tmpStr, 4); found += getDigits(&source[sourceIdx], tmpStr, 4);
zone = atoi(tmpStr) * sign; if (found > 0)
{
sourceIdx += found;
if (found == 2)
{
zone *= 100; // Convert 2 digits to 4
}
zone = atoi(tmpStr);
tz = [NSTimeZone timeZoneForSecondsFromGMT: tz = [NSTimeZone timeZoneForSecondsFromGMT:
(zone / 100 * 60 + (zone % 100)) * 60]; sign * ((zone / 100) * 60 + (zone % 100)) * 60];
}
} }
break; break;