| Type: | Package | 
| Title: | R API for 'Date' and 'Datetime' | 
| Version: | 0.0.9 | 
| Date: | 2024-01-23 | 
| Author: | Dirk Eddelbuettel | 
| Maintainer: | Dirk Eddelbuettel <edd@debian.org> | 
| Description: | Access to the C-level R date and 'datetime' code is provided for C-level API use by other packages via registration of native functions. Client packages simply include a single header 'RApiDatetime.h' provided by this package, and also 'import' it. The R Core group is the original author of the code made available with slight modifications by this package. | 
| URL: | https://github.com/eddelbuettel/rapidatetime, https://dirk.eddelbuettel.com/code/rapidatetime.html | 
| BugReports: | https://github.com/eddelbuettel/rapidatetime/issues | 
| License: | GPL-2 | GPL-3 [expanded from: GPL (≥ 2)] | 
| RoxygenNote: | 6.0.1 | 
| OS_type: | unix | 
| NeedsCompilation: | yes | 
| Packaged: | 2024-01-23 18:03:35 UTC; edd | 
| Repository: | CRAN | 
| Date/Publication: | 2024-01-24 15:22:50 UTC | 
R API for 'Date' and 'Datetime'
Description
Access to the C-level R date and 'datetime' code is provided for C-level API use by other packages via registration of native functions. Client packages simply include a single header 'RApiDatetime.h' provided by this package, and also 'import' it. The R Core group is the original author of the code made available with slight modifications by this package.
Package Content
Index of help topics:
RApiDatetime-package R API for 'Date' and 'Datetime' asDatePOSIXct Conversion from POSIXct to Date rapistrptime R Wrappers for 'strptime', 'asPOSIXlt' etc
Maintainer
Dirk Eddelbuettel <edd@debian.org>
Author(s)
Dirk Eddelbuettel
Conversion from POSIXct to Date
Description
Conversion from POSIXct to Date
Usage
asDatePOSIXct(x, tz = "")
Arguments
| x | A POSIXct vector | 
| tz | An optional timezone string | 
Details
This function provides a direct conversion from POSIXct to Date. As of R-3.5.1, conversion from POSIXct to Date creates an intermediate POSIXlt object. This intermediate POSIXlt object uses a non-trivial amount of memory. The direct conversion is more memory efficient, and therefore approximately twice as fast as the current solution in base R.
Value
A vector of Date objects
Author(s)
Joshua Ulrich
Examples
p <- .POSIXct(1540181413, "America/Chicago")
as.Date(p)                     # Using UTC timezone
as.Date(p, "America/Chicago")  # Using local timezone
asDatePOSIXct(p)               # Direct, using local timezone
R Wrappers for strptime, asPOSIXlt etc
Description
Wrappers for C-level strptime etc functions
Usage
rapistrptime(x, fmt, tz = "")
rapiAsPOSIXlt(x, tz = "")
rapiAsPOSIXct(x, tz = "")
rapiFormatPOSIXlt(x, fmt, usetz = FALSE)
rapiPOSIXlt2D(x)
rapiD2POSIXlt(x)
Arguments
| x | Vector with one or character elements to be parsed | 
| fmt | The format string, see  | 
| tz | An optional timezone string | 
| usetz | An optional logical variable selecting use of the timezone. | 
Details
These functions provide (additional) entry points from R to the C-level function of the R API. They are provided here mainly for testing (the C level access) as R itself exposes the function
Value
A vector with POSIXlt datetime objects
Author(s)
Dirk Eddelbuettel
Examples
op <- options(digits.secs=6)
x <- rapistrptime("2017-01-02 03:04:05.678", "%Y-%m-%d %H:%M:%OS")
format(x)
rapiAsPOSIXlt(as.POSIXct(x))
rapiAsPOSIXct(x)
rapiFormatPOSIXlt(x, "%Y-%b-%d %H:%M:%OS")
options(op)
rapiPOSIXlt2D(x)
rapiD2POSIXlt(as.Date("2017-01-02"))