Documentation
¶
Index ¶
- Constants
- Variables
- func AddMonths(t time.Time, delta int) time.Time
- func AlignTimeWithStepEnd(endTime time.Time, step TimeStep) time.Time
- func AlignTimeWithStepStart(startTime time.Time, step TimeStep) time.Time
- func AssertAdjacentTimeSegmentsAreNonIntersecting(segments []TimeSegment) error
- func AssertAdjacentTimeSegmentsAreNonOverlapping(segments []TimeSegment) error
- func AssertTimeSegmentsAreContinuous(segments []TimeSegment) error
- func Compare(a time.Time, b time.Time) bool
- func Copy(t *time.Time) *time.Time
- func ExtractBoundariesFromTimeSegments(timeSegments []TimeSegment, extraBoundaries ...time.Time) ([]time.Time, error)
- func FirstDayOfTheMonth(t time.Time) time.Time
- func IsZero(a *time.Time) bool
- func LastDayOfTheMonth(t time.Time) time.Time
- func MustParseTime(format string, s string) time.Time
- func PtrCompare(a *time.Time, b *time.Time) bool
- func PtrTo(t time.Time) *time.Time
- func StartOfTheDay(t time.Time) time.Time
- func StartOfTheHour(t time.Time) time.Time
- func TimeBetweenExclusive(now time.Time, startTime time.Time, endTime time.Time) bool
- func TimeBetweenInclusive(now time.Time, startTime time.Time, endTime time.Time) bool
- func TimeIsAlignedWithTimeStep(time time.Time, step TimeStep) bool
- func Weekday(t time.Time, weekday time.Weekday) time.Time
- func Zero() *time.Time
- type StepAlignedTimeSegment
- type TimeSegment
- func (t TimeSegment) Align(timeStep TimeStep) StepAlignedTimeSegment
- func (t TimeSegment) AssertIsComposedOf(subSegments []TimeSegment) error
- func (t TimeSegment) Clip(boundary TimeSegment) TimeSegment
- func (t TimeSegment) Contains(toTest time.Time, includeEdges bool) bool
- func (t TimeSegment) ContainsTimeSegment(other TimeSegment, includeEdges bool) bool
- func (t TimeSegment) CountTimeStepBoundaries(timeStep TimeStep) int
- func (t TimeSegment) Decompose(boundaries []time.Time, decomposeInto []TimeStep, greedy bool) ([]StepAlignedTimeSegment, error)
- func (t TimeSegment) Duration() time.Duration
- func (t TimeSegment) ExecuteOncePerBoundary(f func(t time.Time) error, timeStep TimeStep) error
- func (t TimeSegment) ExecuteOncePerDuration(function func(t TimeSegment) error, d time.Duration) error
- func (t TimeSegment) ExecuteOncePerTimeStep(f func(t TimeSegment) error, timeStep TimeStep) error
- func (t TimeSegment) Format(layout string) string
- func (t TimeSegment) Intersect(other TimeSegment) (TimeSegment, bool)
- func (t TimeSegment) Intersecting(other TimeSegment, includeBoundaries bool) bool
- func (t TimeSegment) IsAlignedWithTimeStep(timeStep TimeStep) bool
- func (t TimeSegment) IsContainedBy(parent TimeSegment, includeEdges bool) bool
- func (t TimeSegment) ListTimeStepBoundaries(timeStep TimeStep) []time.Time
- func (t TimeSegment) Overlaps(other TimeSegment, includeEdges bool) bool
- func (t TimeSegment) SplitByDuration(d time.Duration) ([]TimeSegment, error)
- func (t TimeSegment) SplitByTimeStep(timeStep TimeStep) ([]StepAlignedTimeSegment, error)
- func (t TimeSegment) UTC() TimeSegment
- type TimeSegmentPair
- type TimeStep
Constants ¶
View Source
const ( OneDay = time.Hour * 24 OneWeek = OneDay * 7 )
Variables ¶
View Source
var InvalidTimeSegmentErr = errors.New("invalid start/end times. End cannot be before start")
Functions ¶
func AlignTimeWithStepStart ¶
func AssertAdjacentTimeSegmentsAreNonIntersecting ¶
func AssertAdjacentTimeSegmentsAreNonIntersecting(segments []TimeSegment) error
func AssertAdjacentTimeSegmentsAreNonOverlapping ¶
func AssertAdjacentTimeSegmentsAreNonOverlapping(segments []TimeSegment) error
func AssertTimeSegmentsAreContinuous ¶
func AssertTimeSegmentsAreContinuous(segments []TimeSegment) error
func TimeBetweenExclusive ¶
func TimeBetweenInclusive ¶
Types ¶
type StepAlignedTimeSegment ¶
type StepAlignedTimeSegment struct {
TimeSegment
TimeStep
}
func AlignTimesWithTimeStep ¶
type TimeSegment ¶
func MustParseTimeSegment ¶
func MustParseTimeSegment(format string, s string, e string) TimeSegment
func NewTimeSegment ¶
func (TimeSegment) Align ¶
func (t TimeSegment) Align(timeStep TimeStep) StepAlignedTimeSegment
func (TimeSegment) AssertIsComposedOf ¶
func (t TimeSegment) AssertIsComposedOf(subSegments []TimeSegment) error
AssertIsComposedOf returns an error if this TimeSegment is not "composed of" the given subSegments
A TimeSegment is "composed of" subSegments if:
- The subSegments are continuous
- The subSegments are non-overlapping
- The subSegments completely cover the TimeSegment
func (TimeSegment) Clip ¶
func (t TimeSegment) Clip(boundary TimeSegment) TimeSegment
func (TimeSegment) Contains ¶
func (t TimeSegment) Contains(toTest time.Time, includeEdges bool) bool
func (TimeSegment) ContainsTimeSegment ¶
func (t TimeSegment) ContainsTimeSegment(other TimeSegment, includeEdges bool) bool
func (TimeSegment) CountTimeStepBoundaries ¶
func (t TimeSegment) CountTimeStepBoundaries(timeStep TimeStep) int
func (TimeSegment) Decompose ¶
func (t TimeSegment) Decompose(boundaries []time.Time, decomposeInto []TimeStep, greedy bool) ([]StepAlignedTimeSegment, error)
Decompose attempts to break this TimeSegment into smaller TimeSegments along the given time boundaries. The output TimeSegments will be aligned with one of the TimeSteps given by decomposeInto. If one or more of the boundary times are not aligned with at least one of the given TimeSteps, the decomposition will fail
func (TimeSegment) Duration ¶
func (t TimeSegment) Duration() time.Duration
func (TimeSegment) ExecuteOncePerBoundary ¶
func (TimeSegment) ExecuteOncePerDuration ¶
func (t TimeSegment) ExecuteOncePerDuration(function func(t TimeSegment) error, d time.Duration) error
func (TimeSegment) ExecuteOncePerTimeStep ¶
func (t TimeSegment) ExecuteOncePerTimeStep(f func(t TimeSegment) error, timeStep TimeStep) error
func (TimeSegment) Format ¶
func (t TimeSegment) Format(layout string) string
func (TimeSegment) Intersect ¶
func (t TimeSegment) Intersect(other TimeSegment) (TimeSegment, bool)
func (TimeSegment) Intersecting ¶
func (t TimeSegment) Intersecting(other TimeSegment, includeBoundaries bool) bool
func (TimeSegment) IsAlignedWithTimeStep ¶
func (t TimeSegment) IsAlignedWithTimeStep(timeStep TimeStep) bool
func (TimeSegment) IsContainedBy ¶
func (t TimeSegment) IsContainedBy(parent TimeSegment, includeEdges bool) bool
func (TimeSegment) ListTimeStepBoundaries ¶
func (t TimeSegment) ListTimeStepBoundaries(timeStep TimeStep) []time.Time
func (TimeSegment) Overlaps ¶
func (t TimeSegment) Overlaps(other TimeSegment, includeEdges bool) bool
func (TimeSegment) SplitByDuration ¶
func (t TimeSegment) SplitByDuration(d time.Duration) ([]TimeSegment, error)
func (TimeSegment) SplitByTimeStep ¶
func (t TimeSegment) SplitByTimeStep(timeStep TimeStep) ([]StepAlignedTimeSegment, error)
SplitByTimeStep returns a slice of segments aligned with time step boundaries. NOTE: The time covered by the returned TimeSegments will extend beyond the original TimeSegment if it wasn't already boundary aligned
func (TimeSegment) UTC ¶
func (t TimeSegment) UTC() TimeSegment
type TimeSegmentPair ¶
type TimeSegmentPair struct {
First TimeSegment
Second TimeSegment
}
func FindAdjacentIntersectingTimeSegments ¶
func FindAdjacentIntersectingTimeSegments(segments []TimeSegment, includeBoundaries bool) []TimeSegmentPair
func FindDiscontinuities ¶
func FindDiscontinuities(segments []TimeSegment) []TimeSegmentPair
Click to show internal directories.
Click to hide internal directories.