• 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: Albert Jagnow <email@hidden>
  • Date: Tue, 16 Sep 2003 23:57:46 -0500

I am pretty sure that NSTimestamp is stored in UTC which is not affected by daylight savings time. If you compare two timestamps where one was stored on October 25 2003 at 2:00AM local time and the other was stored on October 26 2003 at 1:00AM local time after the time change, these dates are 24 hours apart even though one is at 2:00 local time and the other is at 1:00 local time. If you look at the UTC time for each in a database (assuming local time is central time) you should see something like 2003-10-25 07:00:00 for the first time and 2003-10-26 07:00:00 for the second. The difference calculation below should give you a diff of 24 hours or 1 day. This is the correct difference is it not?

--Albert

On Tuesday, September 16, 2003, at 07:59  PM, Denis Stanton wrote:


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.

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

  • Prev by Date: Re: NSNumberFormatter & NSTimestamp -- Not Happening
  • Next by Date: Re: Which datatype? NSMutableArray, Vector, Array ???
  • Previous by thread: Re: NSNumberFormatter & NSTimestamp -- Not Happening
  • Next by thread: RE: NSNumberFormatter & NSTimestamp -- Not Happening
  • Index(es):
    • Date
    • Thread