Skip to content
Back to formatted view

Raw Message

Message-ID: <20824.11232.561437.906593@max.nulle.part>
Date: 2013-03-31T12:28:16Z
From: Dirk Eddelbuettel
Subject: [Rcpp-devel] Datetime substraction bug ?
In-Reply-To: <CAJJHHA-=7co_nohK2UjOtCqeMOeWic46mCk7yiviq0pW0ac5HQ@mail.gmail.com>

I don't really understand all the excitement here.  

It's quick enough to define a function to do what you want, no?

R> NewYear <- as.Date("2013-01-01")
R> Easter <- Sys.Date()
R> cppFunction('double ddiff(Date a, Date b) { return a - b; }')
R> cppFunction('double ddiff2(Date a, Date b) { return b - a; }')
R> ddiff(NewYear, Easter)
[1] 89                            ## I find this more logical
R> ddiff2(NewYear, Easter)
[1] -89                           ## closer to R's difftime and 'odd' to me
R> 

Dirk

-- 
Dirk Eddelbuettel | edd at debian.org | http://dirk.eddelbuettel.com