Products | Versions |
---|---|
Spotfire Enterprise Runtime for R | All supported versions |
Spotfire Desktop | All supported versions |
This article presents example commands that can be adapted for use in a Spotfire data function's TERR script to adjust the time zone of a POSIXct column in an input data set, using core functions in TERR.
(1) The first example changes the timezone label without shifting the date and time.
(2) The second example shifts the date and time without changing the timezone label.
(3) The third example does both.
~~~
# Examples of time zone manipulation
# with objects of class "POSIXct"
# using core functions in TERR:
# (0) This creates an example date-time group (DTG) with the machine's local time zone:
TestDTG <- Sys.time()
class(TestDTG)
TestDTG
# (1) This changes the timezone label to "UTC" without shifting the date and time:
RelabeledTestDTG <-
as.POSIXct(as.character(TestDTG), tz = "UTC")
RelabeledTestDTG
# (2) This shifts the date and time to the "UTC" time zone without changing the timezone label:
ShiftedTestDTG <-
as.POSIXct(format(TestDTG, tz = "UTC", usetz = TRUE))
ShiftedTestDTG
# (3) This does both:
ShiftedAndRelabeledTestDTG <-
as.POSIXct(
as.character(
as.POSIXct(format(TestDTG, tz = "UTC", usetz = TRUE))),
tz = "UTC")
ShiftedAndRelabeledTestDTG
Demonstration in a TERR Console session:
Disclaimer:
The code in this article is only a sample to be used as a reference. It is not intended to be used "As Is" in a Production environment. Always test in a Development environment. Make modifications to the code in accordance with your implementation specifications that best suit your business requirements. Refer to the reference(s) cited in this article for usage of the functions and methods used in the code.
Refer to the KB article# 000031003 for background information on how the Spotfire data function framework transfers date/time information between Spotfire and TIBCO Enterprise Runtime for R (TERR)