File: interval.R

package info (click to toggle)
r-cran-spacetime 1.3-3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,240 kB
  • sloc: sh: 13; makefile: 2
file content (39 lines) | stat: -rw-r--r-- 1,013 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
if (!isGeneric("timeIsInterval"))
	setGeneric("timeIsInterval", function(x, ...)
		standardGeneric("timeIsInterval"))

if (!isGeneric("timeIsInterval<-"))
	setGeneric("timeIsInterval<-", function(x, value)
		standardGeneric("timeIsInterval<-"))

setMethod("timeIsInterval", "ST",
	function(x, ...) {
		any(as.POSIXct(index(x@time)) < x@endTime)
	}
)

setMethod("timeIsInterval", "ANY",
	function(x, ...) {
		stop("timeIsInterval is not supported any longer; time intervals are obtained by specifying endTime")
	}
)

setReplaceMethod("timeIsInterval", c("ST", "logical"),
	function(x, value) {
		if (isTRUE(value)) {
			if (min(diff(index(x@time))) <= 0)
				warning("zero-width time intervals may yield invalid matching results")
			x@endTime = delta(x@time)
		}
		x
	}
)

setReplaceMethod("timeIsInterval", c("ANY", "logical"),
	function(x, value) {
		stop("timeIsInterval<- is not supported any longer; time intervals are obtained by specifying endTime")
	}
)

if (!isClass("Intervals"))
	setClass("Intervals")