• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSTimestamp.timestampByAddingGregorianUnits considered harmful
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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
  • Follow-Ups:
    • Re: NSTimestamp.timestampByAddingGregorianUnits considered harmful
      • From: Timo Hoepfner <email@hidden>
References: 
 >NSTimestamp.timestampByAddingGregorianUnits considered harmful (From: Timo Hoepfner <email@hidden>)
 >Re: NSTimestamp.timestampByAddingGregorianUnits considered harmful (From: Chuck Hill <email@hidden>)

  • Prev by Date: Re: Migrations and OpenBase
  • Next by Date: Re: eogenerate ant task?
  • Previous by thread: Re: NSTimestamp.timestampByAddingGregorianUnits considered harmful
  • Next by thread: Re: NSTimestamp.timestampByAddingGregorianUnits considered harmful
  • Index(es):
    • Date
    • Thread