• 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: NSNumberFormatter & NSTimestamp -- Not Happening
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSNumberFormatter & NSTimestamp -- Not Happening


  • Subject: Re: NSNumberFormatter & NSTimestamp -- Not Happening
  • From: Denis Stanton <email@hidden>
  • Date: Thu, 18 Sep 2003 17:31:38 +1200

Hi Chuck

On Thursday, September 18, 2003, at 04:02  AM, Chuck Hill wrote:

When doing things like this I prefer noon, rather than midnight, as a
reference time:

I am using noon - in my time zone. Noon in NZ is midnight in Greenwich. :)

NSTimeZone timeZone = NSTimeZone.systemTimeZone();
outDate = new NSTimestamp(dateYear, dateMonth, dateDay, 12, 0, 0, timeZone);


Then it does not matter it if gets moved to 11AM or 1PM, the day is still
the same.


Does that make it better for your case?

In this case it doesn't help. Sure it keeps the same day, but that's not the issue. When calculating the interval between two dates one has to subtract milliseconds from milliseconds and then divide by 24 * 60 * 60 to get days. The simple calculation assumes that the result will be an integer, but in fact the existence of 23 hour days means the result may be say 6.85 days, when you were expecting 7. The work around is to always add an extra hour (there will be only a maximum of one short day in any interval, because each 23 hour day is balance by a 25 hour one at the other end of the summer) before dividing by 24 * 60 * 60 and then truncating to int.



Denis _______________________________________________ webobjects-dev mailing list | email@hidden Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/webobjects-dev Do not post admin requests to the list. They will be ignored.

References: 
 >Re: NSNumberFormatter & NSTimestamp -- Not Happening (From: Chuck Hill <email@hidden>)

  • Prev by Date: Re: EOGeneralAdaptorException -- updateValuesInRowDescribedByQualifier
  • Next by Date: Re: Using Custom Data types in EOModeler
  • Previous by thread: Re: NSNumberFormatter & NSTimestamp -- Not Happening
  • Next by thread: Re: NSNumberFormatter & NSTimestamp -- Not Happening
  • Index(es):
    • Date
    • Thread