Discussion:
[racket] min and max representable dates
Jordan Johnson
2015-03-02 00:07:57 UTC
Permalink
Hi all,

Am I right in thinking the min and max dates that racket/date can handle are platform-dependent? If so, is there any constant I can reasonably use as a least or greatest representable date?

I’ve looked in racket/date.rkt and see that there’s some code that appears to be doing binsearch on greatest/least values that seconds->date will accept without error, and eventually I gave up chasing seconds->date down the rabbit hole of racket/base. I really don’t want to get into putting the same binsearch code into my library, but need plausible-yet-safe min/max values.

Context: I’m working on RFC6265 cookie support, and there are some places where the RFC calls for these min/max values explicitly. I expect a pretty conservative estimate is A-OK if it’d be sure of not throwing an error on 32+-bit systems; I see 2^32 seconds would get us at least to the year 2106...

Best,
jmj
____________________
Racket Users list:
http://lists.racket-lang.
Hendrik Boom
2015-03-02 14:59:25 UTC
Permalink
Post by Jordan Johnson
I expect a pretty conservative estimate is A-OK if it’d be sure of
not throwing an error on 32+-bit systems;
I see 2^32 seconds would get us at least to the year 2106...
Which is why the world is shifting to 64-bit dates.

If we don't do this, Unix's Y2K event is expected by around 2038 I
think that may be when the date invades the sign bit.

-- hendrik
____________________
Jordan Johnson
2015-03-02 18:41:13 UTC
Permalink
Post by Hendrik Boom
Post by Jordan Johnson
I expect a pretty conservative estimate is A-OK if it’d be sure of
not throwing an error on 32+-bit systems;
I see 2^32 seconds would get us at least to the year 2106...
Which is why the world is shifting to 64-bit dates.
Yes, so I’d feel a lot more comfortable if I can give a bigger max than 2^32 (which I expect I can, but want to check). I found that in Racket v6.1.1 the max is 2^31 - 1. In v6.1.1.8 all I’ve determined is that the max is somewhere between 2^55 and 2^56, on the machine I have access to at the moment. I’d be perfectly happy to take 2^55 as the constant, IF it will work on all machines; that’d give 1.1 billion years to implement an improvement. With a coffee break, even.

Best,
jmj


____________________
Racket User
Hendrik Boom
2015-03-02 19:13:35 UTC
Permalink
Post by Jordan Johnson
Yes, so I’d feel a lot more comfortable if I can give a bigger max
than 2^32 (which I expect I can, but want to check). I found that in
Racket v6.1.1 the max is 2^31 - 1. In v6.1.1.8 all I’ve determined is
that the max is somewhere between 2^55 and 2^56, on the machine I have
access to at the moment. I’d be perfectly happy to take 2^55 as the
constant, IF it will work on all machines; that’d give 1.1 billion
years to implement an improvement. With a coffee break, even.
That's not even as long as the age of the universe.

When the sun turns into a red giant, people will tUrn to your program
to record the event and What!! No time!

-- hendrik.
____________________
Racket Users list:
http://

Loading...