1 2# This R package is free software; you can redistribute it and/or 3# modify it under the terms of the GNU Library General Public 4# License as published by the Free Software Foundation; either 5# version 2 of the License, or (at your option) any later version. 6# 7# This R package is distributed in the hope that it will be useful, 8# but WITHOUT ANY WARRANTY; without even the implied warranty of 9# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10# GNU Library General Public License for more details. 11# 12# You should have received a copy of the GNU Library General 13# Public License along with this R package; if not, write to the 14# Free Foundation, Inc., 59 Temple Place, Suite 330, Boston, 15# MA 02111-1307 USA 16 17 18################################################################################ 19# MEHODS: DESCRIPTION: 20# Ops.timeDate Group 'Ops' operations on 'timeDate' objects 21# +.timeDate Performs + operation on 'timeDate' objects 22# -.timeDate Performs - operation on 'timeDate' objects 23################################################################################ 24 25# ---------------------------------------------------------------------------- # 26# Roxygen Tags 27#' @export 28# ---------------------------------------------------------------------------- # 29setMethod("Ops", c("timeDate", "timeDate"), 30 function(e1, e2) 31{ 32 # A function implemented by Diethelm Wuertz and Yohan Chalabi 33 34 # Description: 35 # Uses group 'Ops' generic functions for 'timeDate' objects 36 37 # Arguments: 38 # e1 - an object of class 'timeDate' 39 # e2 - an object of class 'timeDate' 40 41 # Value: 42 # Returns the 'Ops' grouped object. 43 44 # FUNCTION: 45 ans <- callGeneric(e1@Data, e2@Data) 46 47 if (inherits(ans, "POSIXt")) 48 ans <- timeDate(as.character(ans), 49 zone = "GMT", FinCenter = e1@FinCenter) 50 51 # Return Value: 52 ans 53}) 54 55 56# ---------------------------------------------------------------------------- # 57# Roxygen Tags 58#' @export 59# ---------------------------------------------------------------------------- # 60setMethod("+", c("timeDate", "numeric"), 61 function(e1, e2) 62{ 63 # A function implemented by Yohan Chalabi and Diethelm Wuertz 64 65 ans <- callGeneric(e1@Data, e2) 66 ans <- timeDate(ans, zone = "GMT", FinCenter = e1@FinCenter) 67 68 # Return Value: 69 ans 70}) 71 72 73# ---------------------------------------------------------------------------- # 74# Roxygen Tags 75#' @export 76# ---------------------------------------------------------------------------- # 77setMethod("+", c("numeric", "timeDate"), 78 function(e1, e2) 79{ 80 # A function implemented by Yohan Chalabi and Diethelm Wuertz 81 82 ans <- callGeneric(e1, e2@Data) 83 ans <- timeDate(ans, zone = "GMT", FinCenter = e2@FinCenter) 84 85 # Return Value: 86 ans 87}) 88 89 90# ---------------------------------------------------------------------------- # 91# Roxygen Tags 92#' @export 93# ---------------------------------------------------------------------------- # 94setMethod("+", c("timeDate", "timeDate"), 95 function(e1, e2) 96{ 97 # A function implemented by Yohan Chalabi and Diethelm Wuertz 98 99 stop("binary '+' is not defined for \"timeDate\" objects") 100}) 101 102 103# ---------------------------------------------------------------------------- # 104# Roxygen Tags 105#' @export 106# ---------------------------------------------------------------------------- # 107setMethod("-", c("timeDate", "numeric"), 108 function(e1, e2) 109{ 110 # A function implemented by Yohan Chalabi and Diethelm Wuertz 111 112 ans <- callGeneric(e1@Data, e2) 113 ans <- timeDate(ans, zone = "GMT", FinCenter = e1@FinCenter) 114 115 # Return Value: 116 ans 117}) 118 119 120# ---------------------------------------------------------------------------- # 121# Roxygen Tags 122#' @export 123# ---------------------------------------------------------------------------- # 124setMethod("-", c("numeric", "timeDate"), 125 function(e1, e2) 126{ 127 # A function implemented by Yohan Chalabi and Diethelm Wuertz 128 129 stop("Can only subtract from timeDate objects") 130}) 131 132 133# ---------------------------------------------------------------------------- # 134# Roxygen Tags 135#' @export 136# ---------------------------------------------------------------------------- # 137setMethod("-", c("timeDate", "timeDate"), 138 function(e1, e2) 139{ 140 # A function implemented by Yohan Chalabi and Diethelm Wuertz 141 142 callGeneric(e1@Data, e2@Data) 143}) 144 145 146################################################################################ 147