R version 4.4.0 RC (2024-04-16 r86468 ucrt) -- "Puppy Cup" Copyright (C) 2024 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > attach(asNamespace("epigrowthfit")) > options(warn = 2L, error = if (interactive()) recover) > > > ## ymd ################################################################# > > x <- c(0, 0.5, NaN, -Inf, Inf) > Dx <- .Date(x) > names(Dx) <- letters[seq_along(Dx)] > > A <- matrix(c(1L, 1L, NA, NA, NA, + 1L, 1L, NA, NA, NA, + 1970L, 1970L, NA, NA, NA), + ncol = 3L, dimnames = list(names(Dx), c("d", "m", "y"))) > R1 <- ymd(Dx, which = "dmy") > R2 <- ymd(Dx, which = "y", drop = TRUE) > > stopifnot(exprs = { + identical(R1, A) + identical(R2, A[, "y", drop = TRUE]) + }) > > > ## .ceiling.Date ####################################################### > ## .floor.Date ####################################################### > > x <- c(0, 0.5, NaN, -Inf, Inf) > Dx <- .Date(x) > names(Dx) <- letters[seq_along(Dx)] > > a1 <- .Date(floor(x)) > a2 <- .Date(ceiling(x)) > names(a1) <- names(a2) <- names(Dx) > stopifnot(exprs = { + identical( .floor.Date(Dx, "day"), a1) + identical(.ceiling.Date(Dx, "day"), a2) + }) > > Dx <- as.Date("1970-07-02") > stopifnot(exprs = { + identical( .floor.Date(Dx, "month"), as.Date("1970-07-01")) + identical(.ceiling.Date(Dx, "month"), as.Date("1970-08-01")) + identical( .floor.Date(Dx, "year"), as.Date("1970-01-01")) + identical(.ceiling.Date(Dx, "year"), as.Date("1971-01-01")) + }) > > proc.time() user system elapsed 0.81 0.09 0.90