timeperiods

package
v0.0.0-...-83dca6d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 23, 2022 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type TimePeriod

type TimePeriod struct {
	Time time.Time
	// contains filtered or unexported fields
}

TimePeriod is a basic type which will know whether a period in time contains data

func CalculateTimePeriodsInRange

func CalculateTimePeriodsInRange(start, end time.Time, period time.Duration) ([]TimePeriod, error)

CalculateTimePeriodsInRange can break down start and end times into time periods eg 1 hourly intervals

type TimePeriodCalculator

type TimePeriodCalculator struct {
	TimePeriods []TimePeriod

	TimeRanges []TimeRange
	// contains filtered or unexported fields
}

TimePeriodCalculator is able analyse a time span and either break them down into chunks, or determine ranges that contain data or not

func (*TimePeriodCalculator) Sort

func (t *TimePeriodCalculator) Sort(desc bool)

Sort will sort the time period asc or desc

type TimeRange

type TimeRange struct {
	StartOfRange   time.Time
	EndOfRange     time.Time
	HasDataInRange bool
}

TimeRange holds a start and end dat range and whether that range contains data

func FindTimeRangesContainingData

func FindTimeRangesContainingData(start, end time.Time, period time.Duration, comparisonTimes []time.Time) ([]TimeRange, error)

FindTimeRangesContainingData will break the start and end into time periods using the provided period it will then check whether any comparisonTimes are within those periods and concatenate them eg if no comparisonTimes match, you will receive 1 TimeRange of Start End with dataInRange = false eg2 if 1 comparisonTime matches in the middle of start and end, you will receive three ranges

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL