From ggrothendieck at gmail.com  Tue Sep 23 17:23:19 2008
From: ggrothendieck at gmail.com (Gabor Grothendieck)
Date: Tue, 23 Sep 2008 11:23:19 -0400
Subject: [Rd] Dates in C api
In-Reply-To: <575EAD86322DA342B50FE422364A9F52084BA34D@NYWEXMB27.msad.ms.com>
References: <575EAD86322DA342B50FE422364A9F52082D528B@NYWEXMB27.msad.ms.com>
	<e8e755250809171319h15fc8461yfd5c7ab1531ad89e@mail.gmail.com>
	<575EAD86322DA342B50FE422364A9F52084BA34D@NYWEXMB27.msad.ms.com>
Message-ID: <971536df0809230823g4f6eedj66190a7feb93bec7@mail.gmail.com>

The chron package does:

library(chron)
times("12:34:56")

Internally times are represented as a faction of a day.

On Mon, Sep 22, 2008 at 3:41 PM, Lee, Philip (IT)
<Phil.Lee at morganstanley.com> wrote:
> r-devel,
>
> One other question just occurred to me - does R have any concept of
> times alone?  I can see that there's dates, and datetimes (POSIXct etc),
> but how should I represent 12:34:56 as just a time?
>
> Thanks,
> Phil
>
>> -----Original Message-----
>> From: Jeff Ryan [mailto:jeff.a.ryan at gmail.com]
>> Sent: Wednesday, September 17, 2008 4:19 PM
>> To: Lee, Philip (IT)
>> Cc: r-devel at r-project.org
>> Subject: Re: [Rd] Dates in C api
>>
>> If you are looking for examples of handling dates/times (specifically
>> POSIXct) within C code, the dev branch of xts has quite a bit of code
>> now.
>>
>> http://r-forge.r-
>> project.org/plugins/scmsvn/viewcvs.php/dev/pkg/src/?root=xts
>>
>> Assigning the class (or any attribute) within the C code will be much
>> faster than doing it outside of C, at least in my experience with
>> larger data.
>>
>> setAttrib(ans, R_ClassSymbol, mkString("Date"))
>>
>> HTH
>> Jeff
>>
>> On Wed, Sep 17, 2008 at 12:24 PM, Lee, Philip (IT)
>> <Phil.Lee at morganstanley.com> wrote:
>> > r-devel,
>> >
>> > I've been trying to write a C plugin for R, and I'm struggling to
>> > understand how dates are represented.
>> >
>> > I can create a date in R:
>> >> mydate<-as.Date(1, origin="1900-01-01") mydate
>> > [1] "1900-01-02"
>> >
>> > When I pass my date to a plugin, though, it's type is that of a
> real.
>> > There doesn't seem to be a date type in Rinternals.h, is there a way
>> to
>> > recognize that a value is a date rather than a real?
>> >
>> > Equally, does anyone know if it's possible to create date values in
>> the
>> > C api?
>> >
>> > Thanks,
>> > Phil Lee
>> >
>> > Philip Lee
>> > Morgan Stanley | Technology
>> > 750 Seventh Avenue, 12th Floor | New York, NY  10019
>> > Phil.Lee at morganstanley.com
>> > --------------------------------------------------------
>> >
>> > NOTICE: If received in error, please destroy and notify sender.
>> Sender does not intend to waive confidentiality or privilege. Use of
>> this email is prohibited when received in error.
>> >
>> > ______________________________________________
>> > R-devel at r-project.org mailing list
>> > https://stat.ethz.ch/mailman/listinfo/r-devel
>> >
>>
>>
>>
>> --
>> Jeffrey Ryan
>> jeffrey.ryan at insightalgo.com
>>
>> ia: insight algorithmics
>> www.insightalgo.com
> --------------------------------------------------------
>
> NOTICE: If received in error, please destroy and notify sender. Sender does not intend to waive confidentiality or privilege. Use of this email is prohibited when received in error.
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>



[Rd] Dates in C api
Gabor Grothendieck