https://github.com/cran/spacetime
Raw File
Tip revision: 955e98ad2d39464cd1c36ec4f7e5c2c70fb6ed37 authored by Edzer Pebesma on 25 January 2021, 11:20:02 UTC
version 1.2-4
Tip revision: 955e98a
interval.R
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")
back to top