Convert Time Zones
Convert a timeDate object to a new time zone.
the time vector object to convert.
the time zone to convert to.
Internally, all timeDate objects are
stored as times in GMT with an associated
time.zone slot. Conversion to the
"local" time zone is done only for the purpose of displaying the
Modifying the time.zone slot directly
alters the time zone of the object, but not the time itself. (It
represents the same instant in a different part of the world.) When
displayed, the time component differs according to the time
difference betwwen the time zones before and after the change.
The function timeZoneConvert modifies the
time zone and the actual time by the time difference between
the new and old time zones. As a result, the printed display of the
timeDate object remains the same (other
than any displayed time zone information). This is useful when
reading in data from a file without specific time zone information
(which, by default, is created with a GMT time zone), and then
converting it to a different local time zone without changing the
printed appearance of the dates and times.
returns the converted timeDate object.
time.out.format="%m/%d/%Y %02H:%02M (%Z)")
date1 <- timeDate("3/22/2002 12:00", zone="GMT")
# 3/22/2002 12:00 (GMT)
date2 <- timeZoneConvert(date1, "PST")
date2 # appears the same as date1, except for zone
# 3/22/2002 12:00 (PST)
date1 - date2 # these times are 8 hours apart
# modifying the time.zone slot does not change
# the actual time, just the display
date3 <- date2
firstname.lastname@example.org <- "EST"
date3 # displays as 3 hours later
# 3/22/2002 15:00 (EST)
date2-date3 # but the difference is zero
# 0d 0h 0m 0s 0MS