Guest User

Untitled

a guest
Aug 21st, 2018
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. Guard against accidental time-zone conversion
  2. > dput(x)
  3. structure(1317830532, class = c("POSIXct", "POSIXt"), tzone = "GMT")
  4. > dput(c(x))
  5. structure(1317830532, class = c("POSIXct", "POSIXt"))
  6. > dput(list(x))
  7. list(structure(1317830532, class = c("POSIXct", "POSIXt"), tzone = "GMT"))
  8. > dput(unlist(list(x)))
  9. 1317830532
  10.  
  11. x <- structure(1317830532, class = c("POSIXct", "POSIXt"),
  12. tzone = "GMT")
  13. y <- structure(1317830532+3600, class = c("POSIXct", "POSIXt"),
  14. tzone = "PST8PDT")
  15. x
  16. [1] "2011-10-05 16:02:12 GMT"
  17.  
  18. y
  19. [1] "2011-10-05 10:02:12 PDT"
  20.  
  21. strftime(c(x, y), format="%Y/%m/%d %H:%M:%S", tz="GMT")
  22. [1] "2011/10/05 16:02:12" "2011/10/05 17:02:12"
  23.  
  24. strftime(c(x, y), format="%Y/%m/%d %H:%M:%S", tz="PST8PDT")
  25. [1] "2011/10/05 09:02:12" "2011/10/05 10:02:12"
  26.  
  27. strftime(unlist(y), format="%Y/%m/%d %H:%M:%S", tz="PST8PDT")
  28. [1] "2011/10/05 10:02:12"
Add Comment
Please, Sign In to add comment