Fast version of as.POSIXct.character for GMT fixed format.
fastPOSIXct
converts timestamps in textual (string) form into
POSIXct
objects. It interprets sequences of digits
separated by non-digits as a timestamp in GMT. The order of
interpretation is fixed: year, month, day, hour, minute, second.
Note that only true (positive) POSIX dates (since 1970-01-01 00:00:00)
are supported and fastPOSIXct
accepts dates up to year 2199.
It is extremely fast (compared to as.POSIXct
by several orders
of magnitude (on some platfroms 1000x faster) since it uses pure text
parsing and no system calls.
fastPOSIXct(x, tz = NULL, required.components = 3L)
x |
string vector to interpret as timestamps |
tz |
timezone for the resulting |
required.components |
minimum number of timestamp components that
are required. For example 3 means only the date is required, 6 means
all components (up to the seconds) are required. If the requirement
is not met, the result for that entry will be |
Numeric vector of the class POSIXct
. In fact this function
computes the numeric vector and calls .POSIXct
to create the
result.
Simon Urbanek
## let us generate a bunch of random timestamps until today ts <- as.character(.POSIXct(runif(1e4) * unclass(Sys.time()), "GMT")) ## convert them using as.POSIXct system.time(a <- as.POSIXct(ts, "GMT")) ## same using the fast method system.time(b <- fastPOSIXct(ts, "GMT")) identical(a, b)
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.