textToEuropeBerlinPosix: Convert Text Timestamps to POSIXct Objects

Description Usage Arguments Details Value Examples

View source: R/textToEuropeBerlinPosix.R

Description

This function tries to overcome some problems that may arise when using as.POSIXct. It can handle timestamps that originate from a clock that switches between standard time and summer time as well as those originating from a clock that stays in standard time over the whole year. See vignette("text_to_posixct", package = "kwb.datetime") for details. It also tries to find a convenient format description string.

Usage

1
textToEuropeBerlinPosix(x, format = NULL, switches = TRUE, dbg = TRUE, ...)

Arguments

x

vector of text (i.e. character) timestamps

format

format string describing the format of a timestamp, such as " placeholders. If not given or NULL, the function tries to guess the format from the first timestamp given in x.

switches

if TRUE (the default), the timestamps are assumed to originate from a clock that switches between standard time and summer time. Otherwise (switches = FALSE) timestamps are assumed to originate from a clock that stays in standard time over the whole year.

dbg

if TRUE debug messages are shown

...

further arguments passed to reformatTimestamp (only relevant if switches = TRUE)

Details

When reading timestamps that observe Daylight Saving, it is required that the timestamps in x are ordered by time, which should be the case if they were recorded by a measuring device.

Value

vector of POSIXct objects

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
# Test the functions with the following "switch" days
kwb.datetime::date_range_CEST(2019)

t1 <- textToEuropeBerlinPosix(c("31.03.2019 01:00", "31.03.2019 03:00"))
t2 <- textToEuropeBerlinPosix(c("31.03.2019 01:00", "31.03.2019 02:00"), 
                              switches = FALSE)
identical(t1, t2)
                              
t3 <- textToEuropeBerlinPosix(c("27.10.2019 02:00", "27.10.2019 02:00"))
t4 <- textToEuropeBerlinPosix(c("27.10.2019 01:00", "27.10.2019 02:00"), 
                              switches = FALSE)
identical(t3, t4)

kwb.datetime::textToEuropeBerlinPosix(c(
  "2017-10-29 01:30:00", # 1: CEST
  "2017-10-29 02:00:00", # 2: CEST
  "2017-10-29 02:30:00", # 3: CEST
  "2017-10-29 02:00:00", # 4: CET
  "2017-10-29 02:30:00", # 5: CET
  "2017-10-29 03:00:00"  # 6: CET
))

KWB-R/kwb.datetime documentation built on July 9, 2021, 10:28 p.m.