git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@23950 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
rfm 2006-10-23 12:24:52 +00:00
parent 2a97010a5c
commit 4fa4c00318
3 changed files with 16 additions and 7 deletions

View file

@ -1,3 +1,8 @@
2006-10-23 Richard Frith-Macdonald <rfm@gnu.org>
* Source/NSCalendarDate: when adding offset to a date, work in
the timezone for the date rather than in GMT ... fixes bug #18088
2006-10-20 Richard Frith-Macdonald <rfm@gnu.org> 2006-10-20 Richard Frith-Macdonald <rfm@gnu.org>
* Source/Additions/GSPrivate.m: * Source/Additions/GSPrivate.m:

View file

@ -68,7 +68,7 @@ extern "C" {
second: (unsigned int)second second: (unsigned int)second
timeZone: (NSTimeZone*)aTimeZone; timeZone: (NSTimeZone*)aTimeZone;
// Retreiving Date Elements // Retrieving Date Elements
- (int) dayOfCommonEra; - (int) dayOfCommonEra;
- (int) dayOfMonth; - (int) dayOfMonth;
- (int) dayOfWeek; - (int) dayOfWeek;

View file

@ -2378,13 +2378,15 @@ static void Grow(DescriptionInfo *info, unsigned size)
NSTimeInterval newOffset; NSTimeInterval newOffset;
int i, year, month, day, hour, minute, second, mil; int i, year, month, day, hour, minute, second, mil;
oldOffset = offset(_time_zone, self); /* Apply timezone offset to _seconds_since_ref from GMT to local time,
/* * then break into components in local time zone.
* Break into components in GMT time zone.
*/ */
GSBreakTime(_seconds_since_ref, &year, &month, &day, &hour, &minute, oldOffset = offset(_time_zone, self);
&second, &mil); s = _seconds_since_ref + oldOffset;
GSBreakTime(s, &year, &month, &day, &hour, &minute, &second, &mil);
/* Apply required offsets to get new local time.
*/
while (years != 0 || months != 0 || days != 0 while (years != 0 || months != 0 || days != 0
|| hours != 0 || minutes != 0 || seconds != 0) || hours != 0 || minutes != 0 || seconds != 0)
{ {
@ -2473,9 +2475,11 @@ static void Grow(DescriptionInfo *info, unsigned size)
} }
/* /*
* Reassemble in GMT time zone. * Reassemble and apply original timezone offset to get
* _seconds_since_ref back to GMT.
*/ */
s = GSTime(day, month, year, hour, minute, second, mil); s = GSTime(day, month, year, hour, minute, second, mil);
s -= oldOffset;
c = [NSCalendarDate alloc]; c = [NSCalendarDate alloc];
c->_calendar_format = cformat; c->_calendar_format = cformat;
c->_time_zone = RETAIN([self timeZone]); c->_time_zone = RETAIN([self timeZone]);