[Rcpp-commits] r3760 - pkg/RcppBDT/demo

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sun Sep 2 03:36:54 CEST 2012


Author: edd
Date: 2012-09-02 03:36:52 +0200 (Sun, 02 Sep 2012)
New Revision: 3760

Added:
   pkg/RcppBDT/demo/RcppBDTtz.R
Modified:
   pkg/RcppBDT/demo/00Index
Log:
added simple demo for TZ


Modified: pkg/RcppBDT/demo/00Index
===================================================================
--- pkg/RcppBDT/demo/00Index	2012-09-01 22:22:11 UTC (rev 3759)
+++ pkg/RcppBDT/demo/00Index	2012-09-02 01:36:52 UTC (rev 3760)
@@ -1 +1,2 @@
-RcppBDT	 Boost Date.Time functionality accessible via Rcpp
+RcppBDT	     Boost Date.Time date functionality demo
+RcppBDTtz    Boost Date.Time timezone functionality demo

Added: pkg/RcppBDT/demo/RcppBDTtz.R
===================================================================
--- pkg/RcppBDT/demo/RcppBDTtz.R	                        (rev 0)
+++ pkg/RcppBDT/demo/RcppBDTtz.R	2012-09-02 01:36:52 UTC (rev 3760)
@@ -0,0 +1,43 @@
+
+demo.RcppBDTtz  <- function() {
+
+    require(utils, quiet=TRUE, warn=FALSE)
+    require(Rcpp, quiet=TRUE, warn=FALSE)
+    require(RcppBDT, quiet=TRUE, warn=FALSE)
+
+    tz <- new(bdtTz, "America/Chicago")
+
+    # format() as cat() enforces txt
+    cat("tz object initialized as:       ", format(tz), "\n")
+    cat("zone std and dst abbreviation:  ", tz$getStdZoneAbbrev(), "and", tz$getDstZoneAbbrev(), "\n")
+    cat("zone std and dst names:         ", tz$getStdZoneName(), "and", tz$getDstZoneName(), "\n")
+
+    # format() as cat() enforces txt
+    cat("2012 year dst start and end:    ", format(tz$getDstLocalStart(2012)), "and", format(tz$getDstLocalEnd(2012)), "\n")
+
+    cat("Offset to UTC (in seconds):     ", tz$getUtcOffset(), "\n")
+    cat("DST offset (in seconds):        ", tz$getDstOffset(), "\n")
+
+    cat("Formal POSIX string of region:  ", tz$getPosixString(), "\n")
+
+    cat("\n")
+    tz1 <- new(bdtTz, "America/Bogota")
+    tz2 <- new(bdtTz, "America/Belize")
+    cat("UTC difference between Bogota and Belize:    ", tz1$getUtcOffset() - tz2$getUtcOffset(), "\n")
+
+    tz1 <- new(bdtTz, "Australia/Sydney")
+    tz2 <- new(bdtTz, "Asia/Singapore")
+    cat("UTC difference between Sidney and Singapore: ", tz1$getUtcOffset() - tz2$getUtcOffset(), "\n")
+
+    tz1 <- new(bdtTz, "Europe/Moscow")
+    tz2 <- new(bdtTz, "Europe/Madrid")
+    cat("UTC difference between Moscow and Madrid:    ", tz1$getUtcOffset() - tz2$getUtcOffset(), "\n")
+
+    cat("\n")
+    cat("First 75 tz regions in database:\n")
+    print(head(tz$getAllRegions(), 75))
+
+
+}
+
+demo.RcppBDTtz()



More information about the Rcpp-commits mailing list