Skip to content
Prev 368335 / 398498 Next

problems in vectors of dates_times

I think a more illuminating inspection is this:
$class
[1] "POSIXct" "POSIXt" 

$tzone
[1] "UTC"
$class
[1] "POSIXct" "POSIXt" 

$tzone
[1] "UTC"
$class
[1] "POSIXct" "POSIXt" 

Note that the operation c(A,B) loses the $tzone attribute.

Note also that C[1] and A[1] are actually the same point in time -- my default time zone, PDT, is 7 hours behind UTC -- but they display differently, due to the different tzone attribute.
[1] "2013-03-27 23:00:00 PDT"
[1] "2013-03-28 06:00:00 UTC"
[1] TRUE

Finally, if I do this:
attributes(C)$tzone <- attributes(A)$tzone

Then they display the same:
[1] "2013-03-28 06:00:00 UTC"
[1] "2013-03-28 06:00:00 UTC"

It's a tossup whether resetting the lost attribute is preferable to setting the system timezone.

Then there's the design question of whether the c() operation should lose the tzone attribute. In this case it would be nice if it didn't, but what should happen if we use c() on two objects with  different tzone attributed??