diff --git a/ChangeLog b/ChangeLog index 5d352411a..5d0e5da5d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -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 diff --git a/Source/NSCalendarDate.m b/Source/NSCalendarDate.m index 479cdb689..429a5dc0b 100644 --- a/Source/NSCalendarDate.m +++ b/Source/NSCalendarDate.m @@ -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;