daytime_modulo: Compare the modulo distance between two 'daytime' objects

View source: R/daytime_arithmetic.R

daytime_moduloR Documentation

Compare the modulo distance between two daytime objects

Description

Compare the modulo distance between two daytime objects

Usage

daytime_modulo(earlier, later)

Arguments

earlier

the earlier of the objects

later

the later of the objects

Details

There is quite a bit of variability in how daytime objects look. Therefore, it is an elusive goal to develop a straightforward subtraction method for determining the time lag between them (although you can try subtract_daytime). This function relies on a priori knowledge of which object occurred earlier and which occurred later. It moves leftward around the circle from the later object to the earlier, recording the number of intervening minutes. But of course, daytime objects do not explicitly reflect the actual day on which the time occurred, so there is no reflection of the number of revolutions involved in actually getting from one timestamp to the next. Instead, the assumption is that they are separated by no more than a day (i.e., the difference will always fall in the interval [0,1440)). In other words, this is not a true difference, only a modulo (hence the function name). This is directly analogous to the fact that various angles can all lie on the same spot of a circle (e.g., , , , etc). Since we don't know the true coefficient for our circumference, we return the modulo.

Examples

t1 <- as_daytime(1000L)
t2 <- as_daytime(1300L)

daytime_modulo(t1, t2) ## 300
daytime_modulo(t2, t1) ## 1140

paulhibbing/daytime documentation built on July 13, 2022, 6:32 p.m.