Support milliseconds when parsing string.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@16314 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-Macdonald 2003-04-01 11:54:11 +00:00
parent cc5dcdcd8d
commit 14778174bf
2 changed files with 12 additions and 6 deletions

View file

@ -1,7 +1,8 @@
2003-04-01 Richard Frith-Macdonald <rfm@gnu.org>
* Source/NSCalendarDate.m: trivial simplification of timezone
handling.
* Source/NSCalendarDate.m: ([initWithString:calendarFormat:locale:])
add support for %F millisecond initialisation.
make trivial simplification of timezone handling.
2003-03-31 Stephane Corthesy <stephane@sente.ch>

View file

@ -587,6 +587,7 @@ static inline int getDigits(const char *from, char *to, int limit)
}
else
{
int milliseconds = 0;
int year = 0, month = 1, day = 1;
int hour = 0, min = 0, sec = 0;
NSTimeZone *tz = nil;
@ -732,8 +733,6 @@ static inline int getDigits(const char *from, char *to, int limit)
//
// WARNING:
// %F, does NOT work.
// and the underlying call has granularity to the second.
// -Most locale stuff is dubious at best.
// -Long day and month names depend on a non-alpha character after the
// last digit to work.
@ -925,7 +924,8 @@ static inline int getDigits(const char *from, char *to, int limit)
break;
case 'F':
NSLog(@"%F format ignored when creating date");
sourceIdx += getDigits(&source[sourceIdx], tmpStr, 3);
milliseconds = atoi(tmpStr);
break;
case 'I': // fall through
@ -1155,13 +1155,18 @@ static inline int getDigits(const char *from, char *to, int limit)
had |= hadD;
}
return [self initWithYear: year
self = [self initWithYear: year
month: month
day: day
hour: hour
minute: min
second: sec
timeZone: tz];
if (self != nil)
{
_seconds_since_ref += ((float)milliseconds) / 1000.0;
}
return self;
}
}