Re: NSTimestamp.timestampByAddingGregorianUnits considered harmful
Re: NSTimestamp.timestampByAddingGregorianUnits considered harmful
- Subject: Re: NSTimestamp.timestampByAddingGregorianUnits considered harmful
- From: Timo Hoepfner <email@hidden>
- Date: Fri, 17 Oct 2008 12:55:30 +0200
Hi,
Daylight Saving TIme?
DST would explain a one hour difference, but not loosing two complete
days (March 2008 for Berlin).
Try NSTimestamp start = new NSTimestamp(year, month, 1, 12, 0, 0,
timezone);
Does that give the right days?
Yes, it does.
I think something like the following is happening:
-At some point timestampByAddingGregorianUnits needs to determine the
number of days of the month(s)
-To do so, it tries to determine the month of the timestamp the
method is called on
-While determining the month, it is using the wrong time zone (GMT?)
-As a result it uses the wrong month for timestamps where the month
differs in the two time zones involved.
If so, you might do better by creating a new timestamp and
subtracting a second. e.g.
NSTimestamp end = new NSTimestamp(year, month + 1, 1, 0, 0, 0,
timezone)stampByAddingGregorianUnits(0, 0, 0, 0, 0, -1);
It's even a bit easier:
end = new NSTimestamp(year, month + 1, 1, 0, 0, -1, timezone);
With this approach, I always get the result I want.
I think I should report a bug...
Thanks for the help,
Timo
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden