• 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: -dateWithTimeIntervalSinceNow: 64-bits may overflow
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: -dateWithTimeIntervalSinceNow: 64-bits may overflow


  • Subject: Re: -dateWithTimeIntervalSinceNow: 64-bits may overflow
  • From: "Stephen J. Butler" <email@hidden>
  • Date: Sun, 09 Oct 2011 14:50:15 -0500

On Sun, Oct 9, 2011 at 1:51 PM, Jerry Krinock <email@hidden> wrote:
>
> On 2011 Oct 08, at 21:12, Stephen J. Butler wrote:
>
>> What's wrong with +[NSDate distantFuture]?
>
> Nothing.  It's only [NSDate -dateWithTimeIntervalSinceNow:FLT_MAX] which sometimes gives unexpected results.

It's not, at least not on 10.6 with Xcode 3.2.5. This program...


#import <Foundation/Foundation.h>

int main (int argc, const char * argv[]) {
    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];

    NSLog( @"distantFuture: %@", [NSDate distantFuture] );
    NSLog( @"FLT_MAX: %@", [NSDate dateWithTimeIntervalSinceNow:FLT_MAX] );

    [pool drain];
    return 0;
}


Gives the output (in 32 and 64 bit):


2011-10-09 14:46:41.639 Untitled[60937:a0f] distantFuture: 4000-12-31
18:00:00 -0600
2011-10-09 14:46:41.640 Untitled[60937:a0f] FLT_MAX: 5828963-12-19
18:00:00 -0600

I think you'll find distantFuture much less buggy than your solution,
seeing as how it isn't going to overflow or run into boundary
situations.
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >-dateWithTimeIntervalSinceNow: 64-bits may overflow (From: Jerry Krinock <email@hidden>)
 >Re: -dateWithTimeIntervalSinceNow: 64-bits may overflow (From: "Stephen J. Butler" <email@hidden>)
 >Re: -dateWithTimeIntervalSinceNow: 64-bits may overflow (From: Jerry Krinock <email@hidden>)

  • Prev by Date: Give a menu keyboard focus - in code
  • Next by Date: Re: Give a menu keyboard focus - in code
  • Previous by thread: Re: -dateWithTimeIntervalSinceNow: 64-bits may overflow
  • Next by thread: Re: -dateWithTimeIntervalSinceNow: 64-bits may overflow
  • Index(es):
    • Date
    • Thread