R Under development (unstable) (2025-01-24 r87627 ucrt) -- "Unsuffered Consequences" Copyright (C) 2025 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. > > demo(RcppBDT, package="RcppBDT") demo(RcppBDT) ---- ~~~~~~~ > demo.RcppBDT <- function() { + + require(RcppBDT, quiet=TRUE, warn=FALSE) + + ## this uses the pretty-printing the Rcpp module logic to show all + ## available functions and their docstring (symbol is not exported) + ## + ## print(bdtMod$date) + + ## we use a base object 'bdt' for the functions below + ## by using the instance stored in the environment + ## + ## alternatively could construct a new instance from bdtMod$date, see R/zzz.R + + cat("Demo of setters\n"); + ## conversions from string commented out, see inst/include/RcppBDT.h for details + ##bdt$fromString("2010-10-02"); cat("From 2010-10-02 : ", format(bdt), "\n") + ##bdt$fromUndelString("20101003"); cat("From 20101003 : ", format(bdt), "\n") + bdt$setFromUTC(); cat("From curr. UTC : ", format(bdt), "\n") + bdt$setFromLocalClock(); cat("From curr. local : ", format(bdt), "\n") + bdt$setEndOfMonth(); cat("end of month : ", format(bdt), "\n") + bdt$setFirstOfNextMonth(); cat("1st of next Month : ", format(bdt), "\n") + bdt$addDays(4); cat("plus four days : ", format(bdt), "\n") + bdt$subtractDays(3); cat("minus three days : ", format(bdt), "\n") + + bdt$setIMMDate(12, 2010); cat("IMM Date Dec 2010 : ", format(bdt), "\n") + bdt$setEndOfBizWeek(); cat("end of biz week : ", format(bdt), "\n") + + cat("\nDemo of getters\n") + ## now just functions that return values to R + cat("From curr. local : ", format(bdt$getLocalClock()), "\n") + bdt$setFromLocalClock(); + cat("end of biz week : ", format(bdt$getEndOfBizWeek()), "\n") + cat("end of of month : ", format(bdt$getEndOfMonth()), "\n") + cat("1st of next month : ", format(bdt$getFirstOfNextMonth()), "\n") + + cat("\nDemo of functions\n") + cat("IMM Date Dec 2010 : ", format(getIMMDate(Dec, 2010)), "\n") + cat("3rd Wed Dec 2010 : ", format(getNthDayOfWeek(third, Wed, Dec, 2010)), "\n") + cat("Last Sat Dec 2010 : ", format(getLastDayOfWeekInMonth(Sat, Dec, 2010)), "\n") + cat("First Sat Dec 2010: ", format(getFirstDayOfWeekInMonth(Sat, Dec, 2010)), "\n") + cat("First Wed in 2011 : ", format(getFirstDayOfWeekAfter(Wed, as.Date("2010-12-31"))), "\n") + cat("Last Wed in 2010 : ", format(getLastDayOfWeekBefore(Wed, as.Date("2010-12-31"))), "\n") + } > demo.RcppBDT() Demo of setters From curr. UTC : 2025-01-25 From curr. local : 2025-01-25 end of month : 2025-01-31 1st of next Month : 2025-02-01 plus four days : 2025-02-05 minus three days : 2025-02-02 IMM Date Dec 2010 : 2010-12-15 end of biz week : 2010-12-17 Demo of getters From curr. local : 2025-01-25 end of biz week : 2025-01-31 end of of month : 2025-01-31 1st of next month : 2025-02-01 Demo of functions IMM Date Dec 2010 : 2010-12-15 3rd Wed Dec 2010 : 2010-12-15 Last Sat Dec 2010 : 2010-12-25 First Sat Dec 2010: 2010-12-04 First Wed in 2011 : 2011-01-05 Last Wed in 2010 : 2010-12-29 > > proc.time() user system elapsed 1.71 0.12 1.84