Re: NSNumberFormatter & NSTimestamp -- Not Happening
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.