format.POSIXctz: format POSIXctz

Description Usage Arguments Details Author(s) Examples

View source: R/timePosixCt.R

Description

appends the gmt offset to the formatted string

Usage

1
2
## S3 method for class 'POSIXctz'
format(x, ...)

Arguments

x

vector of POSIXctz to be printed

...

further arguments to format.POSIXct

Details

Formats the time according to format.POSIXct and adds a space and the $gmtoff of POSIXlt in a format that conforms to %z in strptime

Author(s)

Thomas Wutzler

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
tmpd<- c("2010-03-28 00:00:00"
        ,"2010-03-28 01:00:00"
        ,"2010-03-28 02:00:00"
        ,"2010-03-28 03:00:00"
        ,"2010-03-28 04:00:00"
)
# third value is not defined when swithing tu CEST
tmp.cetz <- as.POSIXct(tmp.lt <- strptime(paste0(tmpd," +0100"),'%Y-%m-%d %H:%M:%S  %z'), tz="CET")
tmp.cetz
as.POSIXctz(tmp.cetz)   # note how the gmt.offset is printed
(tmpDs <- data.frame( timestamp=as.POSIXctz(tmp.cetz) )) # note how the time offset is printed
#write.csv( tmpDs, "tmp/testTimestamp1.csv", row.names = FALSE)
# str(res <- read.csv("tmp/testTimestamp1.csv", colClasses=(timestamp="POSIXct")))
# res$timestamp
#
# test writing in a different time zone
(tmp.cet2 <- structure(tmp.cetz, tzone="EET"))
#trace(format.POSIXctz, recover)
as.POSIXctz(tmp.cet2)
(tmpDs2 <- data.frame( timestamp=as.POSIXctz(tmp.cet2) )) 
#write.csv( tmpDs2, "tmp/testTimestamp2.csv", row.names = FALSE)
# read.csv("tmp/testTimestamp2.csv", colClasses=(timestamp="POSIXct"))[1,1] # does not work
# res<-  read.csv("tmp/testTimestamp2.csv", colClasses=(timestamp="POSIXctz")); res$timestamp

twMisc documentation built on May 2, 2019, 6:11 p.m.