No. Sorry. A POSIXct vector can have only one timezone. Kind of goes along with the whole vectorization thing.
You could fake it with lists, but they are dramatically less convenient. I suppose you could also fake it by developing your own variation on the POSIXct class... but that would be rather slower than the standard version. On June 4, 2021 11:20:07 AM PDT, Thomas Bulka <thomas.tb.bu...@gmail.com> wrote: >Hello list, > >I do have a hard time handling date and time data with different >timezone offsets. Say, I have two strings which represent different >dates/times, like so: > >DT1 <- "2021-06-19T13:45:00-03:00" >DT2 <- "2020-07-20T11:39:12+02:00" >my_dates <- c(DT1, DT2) > >What I want to do now, is to covert those strings into some kind of >datetime object which allows for comparisons (earlier/later etc.). > >Using as_datetime from the lubridate package seems to do the trick, >but it converts DT1 and DT2 with reference to UTC. I guess, this makes >sense from a computational point of view, since, most likely, this is >how R internally handles dates and times. > >However, I would like to be able to at least visually distinguish the >different timezone offsets, if the data is printed. I'm able to >manually set a timezone with the tz parameter of as_datetime: > >as_datetime(DT1, tz = "EDT") >[1] "2020-07-20 09:39:12 EDT" > >But this only works if I enter the timezone manually. > >So what I want to ask is this: Is there any possibility, to convert >all entries of a vector my_dates (see above) into datetime objects >while keeping a visual indication of each timezone offset when the >data is printed? > >Please excuse any awkward phrasing; being pretty new to R, I probably >did not phrase anything correctly. > >Thank you very much in advance! > >Thomas > >______________________________________________ >R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see >https://stat.ethz.ch/mailman/listinfo/r-help >PLEASE do read the posting guide >http://www.R-project.org/posting-guide.html >and provide commented, minimal, self-contained, reproducible code. -- Sent from my phone. Please excuse my brevity. ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.