struct TCal::TimePeriod

Overview

An interval between two Time.

Defined in:

t_cal/period/time_period.cr

Constant Summary

EARLY_HOUR = 7
LATE_HOUR = 22

Constructors

Instance Method Summary

Instance methods inherited from struct TCal::Period(Time)

end : T end, start : T start

Constructor methods inherited from struct TCal::Period(Time)

new(start : T, end __arg0 : T) new

Class methods inherited from struct TCal::Period(Time)

merge(periods : Array(U)) : Array(U) forall U merge

Constructor Detail

def self.new(start : T, end __arg0 : T) #

[View source]

Instance Method Detail

def all_day : self #

Returns a period that starts and ends at midnight on the same dates as this one. If any part of the end date is covered, the resulting period will cover the entire day, ending at midnight of the next day.


[View source]
def each_month : Iterator(Time) #

Iterates over each month in the interval, #at_beginning_of_month. Includes the months containing both the start and end of the interval. Note since the end time is exclusive, if it is exactly at the beginning of a month, that month will not be included.


[View source]
def each_sunday_week : Iterator(Time) #

Iterates over each week in the interval, #at_beginning_of_sunday_week. Includes the weeks containing both the start and end of the interval. Note since the end time is exclusive, if it is exactly at the beginning of a week, that week will not be included.


[View source]
def snap_to_midnight : self #

If this period's start or end fall within the period from LATE_HOUR to EARLY_HOUR, returns a new period with the offending field(s) set to midnight.

If this would result in an empty period, instead returns self.


[View source]
def split_at_sunday : Array(self) #

Splits this period at Saturday/Sunday boundaries.


[View source]
def to_date_period : DatePeriod #

Converts this period to a DatePeriod, discarding the time information.


[View source]