View source: R/daytime_arithmetic.R
daytime_modulo | R Documentation |
daytime
objectsCompare the modulo distance between two daytime
objects
daytime_modulo(earlier, later)
earlier |
the earlier of the objects |
later |
the later of the objects |
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., 2π, 4π, 6π,
etc). Since we don't know the true coefficient for our circumference, we
return the modulo.
t1 <- as_daytime(1000L) t2 <- as_daytime(1300L) daytime_modulo(t1, t2) ## 300 daytime_modulo(t2, t1) ## 1140
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.