timeDate and date-time classes

Prof Brian Ripley ripley at stats.ox.ac.uk
Tue Apr 13 12:58:51 CEST 2010


We are changing some of the internals of date-time classes in R-devel,
which affects people who want to assign to slots of S4 class
"POSIXct".  I've attached a patch for timeDate -- of course
2.12.0 is months off, but the idea is to cover the changes under
a .POSIXct function.

I notice you use "GMT": since that can be confusing (it is used by 
Microsoft as the name of the UK timezone), "UTC" is both clearer and 
more politically correct.

Since several packages depends directly or indirectly on timeDate we 
would appreciate an early update for CRAN.

Brian Ripley

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595
-------------- next part --------------
diff -ru orig/timeDate/R/stats-kurtosis.R timeDate/R/stats-kurtosis.R
--- orig/timeDate/R/stats-kurtosis.R	2009-10-24 03:19:11.000000000 +0100
+++ timeDate/R/stats-kurtosis.R	2010-04-13 08:35:58.000000000 +0100
@@ -114,7 +114,7 @@
     # FUNCTION:
 
     # Return Value:
-    structure(kurtosis(unclass(x), ...), class = c("POSIXt", "POSIXct"))
+    structure(kurtosis(unclass(x), ...), class = oldClass(x))
 }
 
 
diff -ru orig/timeDate/R/stats-skewness.R timeDate/R/stats-skewness.R
--- orig/timeDate/R/stats-skewness.R	2009-10-24 03:19:11.000000000 +0100
+++ timeDate/R/stats-skewness.R	2010-04-13 08:35:42.000000000 +0100
@@ -115,7 +115,7 @@
     # FUNCTION:
 
     # Return Value:
-    structure(skewness(unclass(x), ...), class = c("POSIXt", "POSIXct"))
+    structure(skewness(unclass(x), ...), class = oldClass(x))
 }
 
 
diff -ru orig/timeDate/R/timeDate.R timeDate/R/timeDate.R
--- orig/timeDate/R/timeDate.R	2009-10-24 03:19:12.000000000 +0100
+++ timeDate/R/timeDate.R	2010-04-13 11:35:26.000000000 +0100
@@ -79,7 +79,6 @@
 
 # ------------------------------------------------------------------------------
 
-
 setMethod("timeDate", "character",
     function(charvec, format = NULL, zone = "", FinCenter = "")
 {
@@ -126,8 +125,10 @@
 
     # faster to create manually the POSIXct object
     # num <- structure(num, class = c("POSIXt", "POSIXct"))
-    class(num) <- c("POSIXt", "POSIXct")
-    attr(num, "tzone") <- "GMT"
+    # class(num) <- c("POSIXt", "POSIXct")
+    # attr(num, "tzone") <- "GMT"
+    num <- if(getRversion() >= "2.12.0") .POSIXct(num, "GMT") else
+        structure(num, class = c("POSIXt", "POSIXct"), tzone = "GMT")
 
     new("timeDate",
         Data = num,


More information about the Rmetrics-core mailing list