# NOT RUN {
## 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)
## same for dates
day <- substr(ts, 1, 10)
system.time(da <- as.Date(day))
system.time(db <- fastDate(day))
identical(da, db)
## some parsing examples
fastPOSIXct("2022-01-05 09:15", "GMT")
fastPOSIXct("22/1/1, the time is 9:15", "GMT")
fastPOSIXct("2022-01-01T09:15:00Z", "GMT")
fastPOSIXct("2201010915", "GMT", fixed=2)
## the same converted to your local time zone
fastPOSIXct("2022-01-05 09:15")
## or ET
fastPOSIXct("2022-01-05 09:15", "US/Eastern")
# }
Run the code above in your browser using DataLab