Skip to content

as.Date() , feature or bug?

7 messages · Uwe Ligges, Bo Peng, Brian Ripley +1 more

#
Under linux and windows,
[1] "6666-06-06"
[1] "1970-01-01"
Feature? Bug? help(as.Date) does not mention this case.

Bo.
#
Bo Peng wrote:

            
Well, bug, if you really want to call it a bug that you cannot represent 
the year 6666. ;-)

I guess this is some overflow in do_POSIXlt2D that is not protected 
against misuse. Don't see the point right now, I have to admit.


 > as.Date("6970-12-31")
[1] "6970-12-31"
 > as.Date("6971-01-01")
[1] "1970-01-01"


So we cannot represent more than 5000 years into the future, roughly 
speaking. *Guess* the problem is that we need more than 4 digits for +/- 
5000 years (sum=10000).

Uwe Ligges
#
So I guess we need a warning message and a line in help(as.Date)?

Bo
#
Bo Peng wrote:

            
Even better a fix (than an *error* message), since the POSIX classes can 
handle the date and I do not (yet) see the reason why Date cannot. But I 
have no time to dig deeper (at least not this week).


Uwe Ligges
1 day later
#
On Wed, 14 Sep 2005, Uwe Ligges wrote:

            
Well, actually they cannot.  There is a limit of dates +/- 5000 years from 
the epoch (1970-01-01).  This should have returned NA, and now does.

What does anyone want such dates for?  I hope there was an extremely good 
reason to spend other people's time on this, and look forward to an 
extremely convincing explanation.
#
Prof Brian Ripley wrote:
I can think of one case where I've seen exact dates that far in the 
future used: astronomical calculations. You may have something like "And 
the next chance you'll get to see Jupiter this close to Venus will be on 
December 12th 8766CE. Just after lunchtime in whatever remains of London 
then.".

Is there an R package for astronomical calculations?

Baz
#
This problem was brought up by Xu Neng <neng.xu at umontreal.ca> in the rpy-list. 

<Quote>
Remember the old times when computer guys thought the year 2000 was
too far away to be worried? In my case, the dates like "6666-06-6" and
"9999-09-09" are used as special missing codings for dates.

If R cannot handle dates later than the year 5000, it is fine. Please
just let the world knows about it. What is really annoying is the fact
that the default date "1970-01-01" is silently used instead of raising
exception. If you are not very careful, you may not even notice this
trick. This is the bug I'm referring to.

Hopefully, the R experts can handle this bug seriously.
</Quote>

Bo