timeperiod

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2024 License: GPL-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Entry

type Entry struct {
	baseconf.IncrementalPkDbEntry[int64] `db:",inline"`

	TimePeriodID     int64           `db:"timeperiod_id"`
	StartTime        types.UnixMilli `db:"start_time"`
	EndTime          types.UnixMilli `db:"end_time"`
	Timezone         string          `db:"timezone"`
	RRule            sql.NullString  `db:"rrule"` // RFC5545 RRULE
	RotationMemberID sql.NullInt64   `db:"rotation_member_id"`
	// contains filtered or unexported fields
}

func (*Entry) Contains

func (e *Entry) Contains(t time.Time) bool

Contains returns whether a point in time t is covered by this entry.

This function may only be called after a successful call to Init().

func (*Entry) IncrementalInitAndValidate

func (e *Entry) IncrementalInitAndValidate() error

IncrementalInitAndValidate implements the config.IncrementalConfigurableInitAndValidatable interface.

func (*Entry) Init

func (e *Entry) Init() error

Init prepares the Entry for use after being read from the database.

This includes loading the timezone information and parsing the recurrence rule if present.

func (*Entry) MarshalLogObject

func (e *Entry) MarshalLogObject(encoder zapcore.ObjectEncoder) error

MarshalLogObject implements the zapcore.ObjectMarshaler interface.

func (*Entry) NextTransition

func (e *Entry) NextTransition(t time.Time) time.Time

NextTransition returns the next recurrence start or end of this entry relative to the given time inclusively. This function returns also time.Time's zero value if there is no transition that starts/ends at/after the specified time.

This function may only be called after a successful call to Init().

func (*Entry) TableName

func (e *Entry) TableName() string

TableName implements the contracts.TableNamer interface.

type TimePeriod

type TimePeriod struct {
	baseconf.IncrementalPkDbEntry[int64] `db:",inline"`

	Name    string   `db:"-"`
	Entries []*Entry `db:"-"`
}

func (*TimePeriod) Contains

func (p *TimePeriod) Contains(t time.Time) bool

Contains returns whether a point in time t is covered by this time period, i.e. there is an entry covering it.

func (*TimePeriod) IncrementalInitAndValidate

func (p *TimePeriod) IncrementalInitAndValidate() error

func (*TimePeriod) MarshalLogObject

func (p *TimePeriod) MarshalLogObject(encoder zapcore.ObjectEncoder) error

MarshalLogObject implements the zapcore.ObjectMarshaler interface.

func (*TimePeriod) NextTransition

func (p *TimePeriod) NextTransition(base time.Time) time.Time

NextTransition returns a time strictly after the given base time when the time period may be entered or exited.

It is guaranteed that for any time t with base < t < p.NextTransition(base), p.Contains(t) == p.Contains(base), i.e. the earliest time a change happens, is at the returned time. Note that for simplicity of the implementation, this specification does not require that a transition happens at the returned time.

func (*TimePeriod) TableName

func (p *TimePeriod) TableName() string

Jump to

Keyboard shortcuts

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