• 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: Wed, 17 Sep 2003 12:59:16 +1200

On Wednesday, September 17, 2003, at 02:48  AM, Albert Jagnow wrote:

If you have two NSTimestamps you can get the number of days between them
using a method something like this:


//this is untested code
public int numOfDays(NSTimestamp start, NSTimestamp end){
	long diff = (end.getTime() - start.getTime()); //diff in ms
	int days = (int)( diff / (24*60*60*1000) );
	return days;
}

I think this routine will have a problem around the change to or from daylight saving time. In most time zones there is one 23 hour day and one 25 hour day each year. The above calculation will be one day out if the date range spans such a change.


A tidy solution to this problem would be appreciated as it is upsetting my own application. maybe the answer is just to add one hour (60*60*1000 ) to diff before dividing.

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.

  • Follow-Ups:
    • Re: NSNumberFormatter & NSTimestamp -- Not Happening
      • From: Albert Jagnow <email@hidden>
  • Prev by Date: Re: wostats - This Request Requires A User Login
  • Next by Date: Re: NSNumberFormatter & NSTimestamp -- Not Happening
  • Previous by thread: RE: NSNumberFormatter & NSTimestamp -- Not Happening
  • Next by thread: Re: NSNumberFormatter & NSTimestamp -- Not Happening
  • Index(es):
    • Date
    • Thread