eddelbuettel / rapidatetime

Datetime functionality from the C API for R
GNU General Public License v2.0
11 stars 5 forks source link

Convert POSIXct to Date directly #2

Closed joshuaulrich closed 6 years ago

joshuaulrich commented 6 years ago

As of R-3.5.1, converting from POSIXct to Date creates an intermediate POSIXlt vector. This uses a non-trivial amount of memory. Directly converting from POSIXct to Date uses less memory and is roughly twice as fast.

This solution is a combination of asPOSIXlt and POSIXlt2D from RCore. The functions are essentially concatenated, with the extraneous parts removed.

The function name 'asDatePOSIXct' differs from the other rapi* names because it's not a RCore function. The name isn't as.Date.POSIXct() to avoid clashes with the current (or future) S3 method.

codecov-io commented 6 years ago

Codecov Report

Merging #2 into master will increase coverage by 1.42%. The diff coverage is 84.78%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master       #2      +/-   ##
==========================================
+ Coverage   53.24%   54.67%   +1.42%     
==========================================
  Files           5        6       +1     
  Lines         971     1017      +46     
==========================================
+ Hits          517      556      +39     
- Misses        454      461       +7
Impacted Files Coverage Δ
R/asDatePOSIXct.R 100% <100%> (ø)
src/init.c 100% <100%> (ø) :arrow_up:
src/datetime.c 66.71% <82.05%> (+0.97%) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 84aa1b0...6bc9320. Read the comment docs.