calendar

package
v0.27.0 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2024 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Event

type Event struct {
	WeekDay *Value
	Year    *Value
	Month   *Value
	Day     *Value
	Hour    *Value
	Minute  *Value
	Second  *Value
	// contains filtered or unexported fields
}

Event represents a calendar event. It can be one specific point in time, or a recurring event

func NewEvent

func NewEvent(initValues ...func(*Event)) *Event

NewEvent instantiates a new event with all its default values

func (*Event) AsTime

func (e *Event) AsTime() (time.Time, bool)

AsTime returns a time.Time representation of the event if possible, if not possible the second value will be false

func (*Event) Field

func (e *Event) Field(typeValue TypeValue) *Value

Field returns a calendar.Value from the type (year, month, day, etc.)

func (*Event) GetAllInBetween

func (e *Event) GetAllInBetween(start, end time.Time) []time.Time

GetAllInBetween returns all activation times of the event in between these two dates. the minimum increment is 1 minute

func (*Event) Input added in v0.16.0

func (e *Event) Input() string

Input represents the original input if parsed

func (*Event) IsDaily

func (e *Event) IsDaily() bool

IsDaily means all events are within a day (from once to multiple times a day)

func (*Event) IsMonthly

func (e *Event) IsMonthly() bool

IsMonthly means all events runs on specific days of the month, and/or specific months.

func (*Event) IsWeekly

func (e *Event) IsWeekly() bool

IsWeekly means all events runs on specific days of the week (every week)

func (*Event) Next

func (e *Event) Next(from time.Time) time.Time

Next returns the next schedule for this event

func (*Event) Parse

func (e *Event) Parse(input string) error

Parse a string into an event

func (*Event) String

func (e *Event) String() string

String representation

type Range

type Range struct {
	Start int
	End   int
}

Range represents a range of values: from Range.Start to Range.End

type TypeValue

type TypeValue int

TypeValue represents the type of a Value

const (
	TypeUnknown TypeValue = iota
	TypeWeekDay
	TypeYear
	TypeMonth
	TypeDay
	TypeHour
	TypeMinute
	TypeSecond
)

TypeValue

type Value

type Value struct {
	// contains filtered or unexported fields
}

Value is represented by either no value, a single value, or a range of values

func NewValue

func NewValue(min, max int) *Value

NewValue creates a new value

func NewValueFromType

func NewValueFromType(t TypeValue) *Value

NewValueFromType creates a new value from a predefined type

func (*Value) AddRange

func (v *Value) AddRange(start int, end int) error

AddRange adds a range of values from start to end

func (*Value) AddValue

func (v *Value) AddValue(value int) error

AddValue adds a new value

func (*Value) GetRangeValues

func (v *Value) GetRangeValues() []int

GetRangeValues returns a list of values

func (*Value) GetRanges

func (v *Value) GetRanges() []Range

GetRanges returns a list or range of values (from Range.Start to Range.End)

func (*Value) GetType

func (v *Value) GetType() TypeValue

GetType returns the defined type

func (*Value) HasContiguousRange

func (v *Value) HasContiguousRange() bool

HasContiguousRange is true when two or more values are contiguous

func (*Value) HasLongContiguousRange

func (v *Value) HasLongContiguousRange() bool

HasLongContiguousRange is true when three or more values are contiguous

func (*Value) HasRange

func (v *Value) HasRange() bool

HasRange is true when at least two values has been set

func (*Value) HasSingleValue

func (v *Value) HasSingleValue() bool

HasSingleValue is true when a exactly one value has been set

func (*Value) HasValue

func (v *Value) HasValue() bool

HasValue is true when one or more value has been set

func (*Value) IsInRange

func (v *Value) IsInRange(ref int) bool

IsInRange check the parameter is in range of Value

func (*Value) MustAddRange

func (v *Value) MustAddRange(min int, max int)

MustAddRange adds a range of values from min to max and panics if an error occurs

func (*Value) MustAddValue

func (v *Value) MustAddValue(value int)

MustAddValue adds a new value and panics if an error arises

func (*Value) Parse

func (v *Value) Parse(input string, postProcess ...postProcessFunc) error

Parse a string into a value

func (*Value) String

func (v *Value) String() string

String representation

Jump to

Keyboard shortcuts

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