Skip to content

Negative years with strptime?

5 messages · Winston Chang, Jeff Ryan, Rui Barradas

#
Hello,

Is there a bug with negative dates? Just see:

seq(as.Date("0000-01-01"), length = 22, by = "-1 year")
  [1] "0000-01-01" "000/-01-01" "000.-01-01" "000--01-01" "000,-01-01"
  [6] "000+-01-01" "000*-01-01" "000)-01-01" "000(-01-01" "000'-01-01"
[11] "00/0-01-01" "00//-01-01" "00/.-01-01" "00/--01-01" "00/,-01-01"
[16] "00/+-01-01" "00/*-01-01" "00/)-01-01" "00/(-01-01" "00/'-01-01"
[21] "00.0-01-01" "00./-01-01"

See the year number: "after" the zero, i.e., downward from zero, the 
printed character is '/' which happens to be the ascii character before 
'0', and before it's '.', etc. This sequence gives the nine ascii 
characters before zero as last digit of the year, then the 10th is '0' 
as (now) expected, then goes to the second digit, etc.

It seems to stop at the first 9, or else we would have some sort of real 
problem.

Anyway, this doesn't look right.

Rui Barradas
Em 10-07-2012 22:17, Winston Chang escreveu:
#
?as.Date

Why would pre 0000 years be handled correctly?  The help file
explicitly states that they likely will not.


Note:

     The default formats follow the rules of the ISO 8601 international
     standard which expresses a day as ?"2001-02-03"?.

     If the date string does not specify the date completely, the
     returned answer may be system-specific.  The most common behaviour
     is to assume that a missing year, month or day is the current one.
     If it specifies a date incorrectly, reliable implementations will
     give an error and the date is reported as ?NA?.  Unfortunately
     some common implementations (such as ?glibc?) are unreliable and
     guess at the intended meaning.

     Years before 1CE (aka 1AD) will probably not be handled correctly.
On Tue, Jul 10, 2012 at 4:59 PM, Rui Barradas <ruipbarradas at sapo.pt> wrote:

  
    
#
On my earlier post I forgot to mention the sessionInfo()

R version 2.15.0 (2012-03-30)
Platform: i386-pc-mingw32/i386 (32-bit)

locale:
[1] LC_COLLATE=Portuguese_Portugal.1252 
LC_CTYPE=Portuguese_Portugal.1252
[3] LC_MONETARY=Portuguese_Portugal.1252 LC_NUMERIC=C 

[5] LC_TIME=Portuguese_Portugal.1252

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base

Rui Barradas

Em 11-07-2012 02:05, Winston Chang escreveu: