Re: [Rd] How to convert time_t to R date object

2014-03-17 Thread Prof Brian Ripley
On 17/03/2014 11:39, Dirk Eddelbuettel wrote: Bill, On 17 March 2014 at 12:54, Bill Wang wrote: | Thanks for your reply, I neede convert time_t to R type in C code, can not use | Rcpp. Maybe Rcpp source code could help me. Start by reading 'Writing R Extensions' and figure out how to send an i

Re: [Rd] How to convert time_t to R date object

2014-03-17 Thread Bill Wang
Hi Sandip, I think that you know on the 64-bit Unix/Linux/OS X platforms, long is 64-bit whereas int and INTEGER are 32-bit, so return directly Integer unexpected problems may occur. Cheers, Bill 2014-03-17 13:24 GMT+08:00 Sandip Nandi : > Hi Bill , > > The following C code may help you , tim

Re: [Rd] How to convert time_t to R date object

2014-03-17 Thread Dirk Eddelbuettel
On 16 March 2014 at 22:24, Sandip Nandi wrote: | Hi Bill , | | The following C code  may help you , time_t is typedef to long int  | | SEXP  getTime() { | |   time_t current_time; |     char* c_time_string; |     current_time = time(NULL); |     c_time_string = ctime(¤t_time); | |    return mk

Re: [Rd] How to convert time_t to R date object

2014-03-17 Thread Dirk Eddelbuettel
Bill, On 17 March 2014 at 12:54, Bill Wang wrote: | Thanks for your reply, I neede convert time_t to R type in C code, can not use | Rcpp. Maybe Rcpp source code could help me. Start by reading 'Writing R Extensions' and figure out how to send an int back and forth. Then cast between int and ti

Re: [Rd] How to convert time_t to R date object

2014-03-16 Thread Sandip Nandi
Hi Bill , The following C code may help you , time_t is typedef to long int SEXP getTime() { time_t current_time; char* c_time_string; current_time = time(NULL); c_time_string = ctime(¤t_time); return mkString(c_time_String); // or if you want to return as int vector return s

Re: [Rd] How to convert time_t to R date object

2014-03-16 Thread Bill Wang
Hi Dirk, Thanks for your reply, I neede convert time_t to R type in C code, can not use Rcpp. Maybe Rcpp source code could help me. Cheers, Bill 2014-03-16 22:55 GMT+08:00 Dirk Eddelbuettel : > > On 16 March 2014 at 18:36, Bill Wang wrote: > | I am writing a R extensions, and I need pass time_

Re: [Rd] How to convert time_t to R date object

2014-03-16 Thread Dirk Eddelbuettel
On 16 March 2014 at 18:36, Bill Wang wrote: | I am writing a R extensions, and I need pass time_t to R in C, but I don't | know how to do. | Can you give me some help? do not use double directly. Just treat it as an int: R> library(Rcpp) R> cppFunction("Date time_t2date(time_t what) { return

[Rd] How to convert time_t to R date object

2014-03-16 Thread Bill Wang
Hi all, I am writing a R extensions, and I need pass time_t to R in C, but I don't know how to do. Can you give me some help? do not use double directly. Thanks, Bill -- *Travel | Programming* *http://freecnpro.net* [[alternative HTML version deleted]]