[R-SIG-Finance] [R-sig-finance] ISO-8601 with time zone designator, format handling with fCalendar/chron

jeam eraslan.cem at gmail.com
Fri Jun 1 12:34:38 CEST 2007


Thanks Gabor, actually I  try to handle it as it is, but substring() solve
the problem, brilliantly...

Regards..



Gabor Grothendieck wrote:
> 
> Here is one improvement.  The sgn line is changed to make the entire
> calculation vectorized:
> 
> library(chron)
> x <- "2005-12-05T00:00:00+02:00"
> x <- c(x, x)
> datetime <- chron(as.Date(x), substring(x, 12, 19))
> sgn <- substring(x, 20, 20)
> sgn <- (sgn == "+") - (sgn == "-")
> offset <- as.numeric(times(paste(substring(x, 21), "00", sep = ":")))
> # or should + be - in next line?
> datetime + sgn * offset
> 
> 
> On 5/31/07, Gabor Grothendieck <ggrothendieck at gmail.com> wrote:
>> Try this:
>>
>> library(chron)
>> x <- "2005-12-05T00:00:00+02:00"
>> datetime <- chron(as.Date(x), substring(x, 12, 19))
>> sgn <- switch(substring(x, 20, 20), "+" = +1, "-" = -1)
>> offset <- as.numeric(times(paste(substring(x, 21), "00", sep = ":")))
>> datetime + sgn * offset
>>
>> # or perhaps the last line should be:
>> datetime - sgn * offset
>>
>> On 5/31/07, jeam <eraslan.cem at gmail.com> wrote:
>> >
>> > Dear All;
>> >
>> > I have searched the forum but couldn't find a similar problem.
>> > Currently I am working with a very large set of XML files and the date
>> is
>> > formatted something like that
>> > (YYYY-MM-DDThh:mm:ss+TZD)
>> >
>> > Ex: "2005-12-05T00:00:00+02:00"
>> >
>> > Previously, I've tried chron and fCalendar but couldn't find a way to
>> import
>> > this data as a time object.
>> >
>> > I think somehow, timeDate may handle it, i tried almost all variations
>> > formats, but couldn't make it work.
>> >
>> > Any help appreciated...
>> >
>> > Regards
>> >
>> > --
>> > View this message in context:
>> http://www.nabble.com/ISO-8601-with-time-zone-designator%2C-format-handling-with-fCalendar-chron-tf3849304.html#a10903450
>> > Sent from the Rmetrics mailing list archive at Nabble.com.
>> >
>> > _______________________________________________
>> > R-SIG-Finance at stat.math.ethz.ch mailing list
>> > https://stat.ethz.ch/mailman/listinfo/r-sig-finance
>> > -- Subscriber-posting only.
>> > -- If you want to post, subscribe first.
>> >
>>
> 
> _______________________________________________
> R-SIG-Finance at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
> -- Subscriber-posting only. 
> -- If you want to post, subscribe first.
> 
> 

-- 
View this message in context: http://www.nabble.com/ISO-8601-with-time-zone-designator%2C-format-handling-with-fCalendar-chron-tf3849304.html#a10910434
Sent from the Rmetrics mailing list archive at Nabble.com.



More information about the R-SIG-Finance mailing list