module VirtualDate::MatchRun

Overview

Where a rule's matching time starts and stops. A VirtualTime with an unconstrained field matches for every value of it, so a rule naming only a day matches the whole of that day: one contiguous stretch, not a match per nanosecond. Both the Scheduler and #next_on need to know where such a stretch ends to move on to the next one.

Defined in:

virtualdate.cr

Constant Summary

MAX_BLOCK_TRANSITIONS = 3

Furthest a single matching stretch is followed across UTC offset changes. Two is already more than any zone puts inside one.

Class Method Summary

Class Method Detail

def self.block_end(vtime : VirtualTime, at : Time, depth : Int32 = 0) : Time #

Returns the last instant of the stretch of matching time that at belongs to.

A rule matches continuously for as long as its finest constrained field holds: minute: 6 matches every instant of that minute, hour: 20 every instant of that hour. Where nothing finer than the date is named, the stretch runs to the end of the day.


[View source]
def self.constrains?(value, size : Int32) : Bool #

Returns whether value narrows a field at all.

A rule letting every value of a field through matches for as long as the field above it does; counting it as a constraint would cut one continuous stretch into as many as the field has values -- a thousand per second for millisecond: 0..999, a billion for the nanoseconds under it -- and the run walk would then step through every one of them.


[View source]
def self.contiguous_last(value, from : Int32, size : Int32) : Int32 #

Returns the largest value at or above from that the field allows with every value between the two allowed as well.

A rule matches continuously for as long as its finest constrained field keeps saying yes, and consecutive allowed values are one stretch, not one each: nanosecond: 0..500_000_000 matches for half of every second, and counting that as five hundred million stretches is what turns a millisecond of window into half a second of work. Read from the bounds, never by walking them.


[View source]