calendar

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2025 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RuleTypeMonthly      = types.RuleTypeMonthly
	RuleTypeWeekly       = types.RuleTypeWeekly
	RuleTypeDaily        = types.RuleTypeDaily
	RuleTypeYearly       = types.RuleTypeYearly
	RuleTypeBusinessDays = types.RuleTypeBusinessDays
	RuleTypeCustom       = types.RuleTypeCustom
)

Constants from types package

Variables

View Source
var (
	ErrInvalidSchedule          = types.ErrInvalidSchedule
	ErrInvalidRule              = types.ErrInvalidRule
	ErrInvalidTimezone          = types.ErrInvalidTimezone
	ErrNoExecutionTime          = types.ErrNoExecutionTime
	ErrBusinessCalendarNotFound = types.ErrBusinessCalendarNotFound
	ErrRuleEvaluatorNotFound    = types.ErrRuleEvaluatorNotFound
)

Error aliases from types package

Functions

func CreateExtraException

func CreateExtraException(date time.Time, extraTimes []*schedule.TimeOfDay, reason string) *schedule.CalendarException

CreateExtraException creates an EXTRA exception with additional execution times

func CreateRescheduleException

func CreateRescheduleException(fromDate, toDate time.Time, reason string) *schedule.CalendarException

CreateRescheduleException creates a RESCHEDULE exception

func CreateSkipException

func CreateSkipException(date time.Time, reason string) *schedule.CalendarException

CreateSkipException creates a SKIP exception for the given date

func CreateUKBusinessCalendar

func CreateUKBusinessCalendar() *schedule.BusinessCalendar

CreateUKBusinessCalendar creates a UK business calendar with bank holidays

func CreateUSBusinessCalendar

func CreateUSBusinessCalendar() *schedule.BusinessCalendar

CreateUSBusinessCalendar creates a US business calendar with common federal holidays

Types

type BusinessCalendarProvider

type BusinessCalendarProvider = types.BusinessCalendarProvider

Type aliases for interfaces and types defined in types package

type BusinessDayInfo

type BusinessDayInfo = types.BusinessDayInfo

Type aliases for interfaces and types defined in types package

type CalendarEngineConfig

type CalendarEngineConfig = types.CalendarEngineConfig

Type aliases for interfaces and types defined in types package

func DefaultCalendarEngineConfig

func DefaultCalendarEngineConfig() *CalendarEngineConfig

DefaultCalendarEngineConfig returns the default configuration

type CalendarEngineOption

type CalendarEngineOption func(*CalendarEngineConfig)

CalendarEngineOption is a functional option for configuring the calendar engine

func WithBusinessCalendarProvider

func WithBusinessCalendarProvider(provider BusinessCalendarProvider) CalendarEngineOption

WithBusinessCalendarProvider sets the business calendar provider

func WithCaching

func WithCaching(cacheConfig *types.CacheConfig) CalendarEngineOption

WithCaching enables caching with the specified configuration

func WithDefaultTimezone

func WithDefaultTimezone(timezone string) CalendarEngineOption

WithDefaultTimezone sets the default timezone

func WithExceptionHandler

func WithExceptionHandler(handler ExceptionHandler) CalendarEngineOption

WithExceptionHandler sets the exception handler

func WithMaxFutureCalculations

func WithMaxFutureCalculations(count int) CalendarEngineOption

WithMaxFutureCalculations sets the maximum future calculations

func WithPerformanceMetrics

func WithPerformanceMetrics(enable bool) CalendarEngineOption

WithPerformanceMetrics enables performance metrics

func WithTimezoneProvider

func WithTimezoneProvider(provider TimezoneProvider) CalendarEngineOption

WithTimezoneProvider sets the timezone provider

type CalendarError

type CalendarError = types.CalendarError

Type aliases for interfaces and types defined in types package

type DSTTransition

type DSTTransition struct {
	Date         time.Time `json:"date"`
	IsStart      bool      `json:"is_start"`      // true for start of DST, false for end
	OffsetBefore int       `json:"offset_before"` // offset in seconds before transition
	OffsetAfter  int       `json:"offset_after"`  // offset in seconds after transition
}

DSTTransition represents a daylight saving time transition

type DefaultEngine

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

DefaultEngine is the default implementation of the Calendar Engine

func NewDefaultEngine

func NewDefaultEngine(options ...CalendarEngineOption) *DefaultEngine

NewDefaultEngine creates a new default calendar engine with the given options

func (*DefaultEngine) CalculateNextRun

func (e *DefaultEngine) CalculateNextRun(ctx context.Context, calendarSchedule *schedule.CalendarSchedule, from time.Time) (*time.Time, error)

CalculateNextRun calculates the next execution time for a calendar schedule

func (*DefaultEngine) CalculateNextRuns

func (e *DefaultEngine) CalculateNextRuns(ctx context.Context, calendarSchedule *schedule.CalendarSchedule, from time.Time, count int) ([]time.Time, error)

CalculateNextRuns calculates the next N execution times for a calendar schedule

func (*DefaultEngine) GetHolidays

func (e *DefaultEngine) GetHolidays(ctx context.Context, businessCalendar *schedule.BusinessCalendar, from, to time.Time) ([]Holiday, error)

GetHolidays returns holidays for a date range from business calendar

func (*DefaultEngine) IsBusinessDay

func (e *DefaultEngine) IsBusinessDay(ctx context.Context, date time.Time, businessCalendar *schedule.BusinessCalendar) (bool, error)

IsBusinessDay checks if a given date is a business day according to business calendar

func (*DefaultEngine) PreviewSchedule

func (e *DefaultEngine) PreviewSchedule(ctx context.Context, calendarSchedule *schedule.CalendarSchedule, from time.Time, count int) (*SchedulePreview, error)

PreviewSchedule generates a preview of execution times for testing/debugging

func (*DefaultEngine) ValidateSchedule

func (e *DefaultEngine) ValidateSchedule(ctx context.Context, calendarSchedule *schedule.CalendarSchedule) error

ValidateSchedule validates a calendar schedule for correctness

type DefaultExceptionHandler

type DefaultExceptionHandler struct{}

DefaultExceptionHandler is the default implementation of ExceptionHandler

func NewDefaultExceptionHandler

func NewDefaultExceptionHandler() *DefaultExceptionHandler

NewDefaultExceptionHandler creates a new default exception handler

func (*DefaultExceptionHandler) ApplyExceptions

func (h *DefaultExceptionHandler) ApplyExceptions(ctx context.Context, times []time.Time, exceptions []*schedule.CalendarException, timezone *time.Location) ([]time.Time, error)

ApplyExceptions applies calendar exceptions to a list of execution times

func (*DefaultExceptionHandler) CountExceptionsByType

CountExceptionsByType returns the count of exceptions by type

func (*DefaultExceptionHandler) GetExceptionOnDate

func (h *DefaultExceptionHandler) GetExceptionOnDate(exceptions []*schedule.CalendarException, date time.Time) *schedule.CalendarException

GetExceptionOnDate returns the exception for a specific date, if any

func (*DefaultExceptionHandler) GetExceptionsByType

GetExceptionsByType returns exceptions of a specific type

func (*DefaultExceptionHandler) GetExceptionsForDateRange

func (h *DefaultExceptionHandler) GetExceptionsForDateRange(exceptions []*schedule.CalendarException, from, to time.Time) []*schedule.CalendarException

GetExceptionsForDateRange returns exceptions that fall within a date range

func (*DefaultExceptionHandler) HasExceptionOnDate

func (h *DefaultExceptionHandler) HasExceptionOnDate(exceptions []*schedule.CalendarException, date time.Time) bool

HasExceptionOnDate checks if there's an exception on a specific date

func (*DefaultExceptionHandler) ValidateExceptions

func (h *DefaultExceptionHandler) ValidateExceptions(ctx context.Context, exceptions []*schedule.CalendarException) error

ValidateExceptions validates a list of calendar exceptions

type DefaultTimezoneProvider

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

DefaultTimezoneProvider is the default implementation of TimezoneProvider

func NewDefaultTimezoneProvider

func NewDefaultTimezoneProvider() *DefaultTimezoneProvider

NewDefaultTimezoneProvider creates a new default timezone provider

func (*DefaultTimezoneProvider) ConvertTime

func (p *DefaultTimezoneProvider) ConvertTime(ctx context.Context, t time.Time, fromTZ, toTZ string) (time.Time, error)

ConvertTime converts a time from one timezone to another

func (*DefaultTimezoneProvider) GetCommonTimezones

func (p *DefaultTimezoneProvider) GetCommonTimezones(ctx context.Context) (map[string][]string, error)

GetCommonTimezones returns a list of commonly used timezones organized by region

func (*DefaultTimezoneProvider) GetDSTTransitions

func (p *DefaultTimezoneProvider) GetDSTTransitions(ctx context.Context, timezone string, year int) ([]DSTTransition, error)

GetDSTTransitions returns the DST transitions for a timezone in a given year

func (*DefaultTimezoneProvider) GetTimezone

func (p *DefaultTimezoneProvider) GetTimezone(ctx context.Context, name string) (*time.Location, error)

GetTimezone returns a timezone by name

func (*DefaultTimezoneProvider) GetTimezoneInfo

func (p *DefaultTimezoneProvider) GetTimezoneInfo(ctx context.Context, name string, at time.Time) (*types.TimezoneInfo, error)

GetTimezoneInfo returns detailed information about a timezone at a specific time

func (*DefaultTimezoneProvider) ListTimezones

func (p *DefaultTimezoneProvider) ListTimezones(ctx context.Context) ([]string, error)

ListTimezones returns available timezones

func (*DefaultTimezoneProvider) ValidateTimezone

func (p *DefaultTimezoneProvider) ValidateTimezone(ctx context.Context, name string) error

ValidateTimezone checks if a timezone name is valid

type Engine

type Engine = types.Engine

Type aliases for interfaces and types defined in types package

type ExceptionHandler

type ExceptionHandler = types.ExceptionHandler

Type aliases for interfaces and types defined in types package

type ExceptionPreview

type ExceptionPreview = types.ExceptionPreview

Type aliases for interfaces and types defined in types package

type ExecutionTime

type ExecutionTime = types.ExecutionTime

Type aliases for interfaces and types defined in types package

type Holiday

type Holiday = types.Holiday

Type aliases for interfaces and types defined in types package

type MemoryBusinessCalendarProvider

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

MemoryBusinessCalendarProvider is an in-memory implementation of BusinessCalendarProvider

func NewMemoryBusinessCalendarProvider

func NewMemoryBusinessCalendarProvider() *MemoryBusinessCalendarProvider

NewMemoryBusinessCalendarProvider creates a new in-memory business calendar provider

func (*MemoryBusinessCalendarProvider) AddBusinessDays

func (p *MemoryBusinessCalendarProvider) AddBusinessDays(ctx context.Context, calendarID string, from time.Time, days int) (time.Time, error)

AddBusinessDays adds the specified number of business days to the given date

func (*MemoryBusinessCalendarProvider) CreateBusinessCalendar

func (p *MemoryBusinessCalendarProvider) CreateBusinessCalendar(ctx context.Context, calendar *schedule.BusinessCalendar) error

CreateBusinessCalendar creates a new business calendar

func (*MemoryBusinessCalendarProvider) DeleteBusinessCalendar

func (p *MemoryBusinessCalendarProvider) DeleteBusinessCalendar(ctx context.Context, calendarID string) error

DeleteBusinessCalendar deletes a business calendar

func (*MemoryBusinessCalendarProvider) GetBusinessCalendar

func (p *MemoryBusinessCalendarProvider) GetBusinessCalendar(ctx context.Context, calendarID string) (*schedule.BusinessCalendar, error)

GetBusinessCalendar retrieves a business calendar by ID

func (*MemoryBusinessCalendarProvider) GetNextBusinessDay

func (p *MemoryBusinessCalendarProvider) GetNextBusinessDay(ctx context.Context, calendarID string, from time.Time) (time.Time, error)

GetNextBusinessDay returns the next business day after the given date

func (*MemoryBusinessCalendarProvider) GetPreviousBusinessDay

func (p *MemoryBusinessCalendarProvider) GetPreviousBusinessDay(ctx context.Context, calendarID string, from time.Time) (time.Time, error)

GetPreviousBusinessDay returns the previous business day before the given date

func (*MemoryBusinessCalendarProvider) IsBusinessDay

func (p *MemoryBusinessCalendarProvider) IsBusinessDay(ctx context.Context, calendarID string, date time.Time) (bool, error)

IsBusinessDay checks if a given date is a business day according to the calendar

func (*MemoryBusinessCalendarProvider) ListBusinessCalendars

func (p *MemoryBusinessCalendarProvider) ListBusinessCalendars(ctx context.Context) ([]*schedule.BusinessCalendar, error)

ListBusinessCalendars lists all available business calendars

func (*MemoryBusinessCalendarProvider) UpdateBusinessCalendar

func (p *MemoryBusinessCalendarProvider) UpdateBusinessCalendar(ctx context.Context, calendar *schedule.BusinessCalendar) error

UpdateBusinessCalendar updates an existing business calendar

type PreviewPeriod

type PreviewPeriod = types.PreviewPeriod

Type aliases for interfaces and types defined in types package

type RuleEvaluator

type RuleEvaluator = types.RuleEvaluator

Type aliases for interfaces and types defined in types package

type RulePreview

type RulePreview = types.RulePreview

Type aliases for interfaces and types defined in types package

type RuleType

type RuleType = types.RuleType

Type aliases for interfaces and types defined in types package

type SchedulePreview

type SchedulePreview = types.SchedulePreview

Type aliases for interfaces and types defined in types package

type TimezoneInfo

type TimezoneInfo struct {
	Name          string         `json:"name"`
	DisplayName   string         `json:"display_name"`
	Abbreviation  string         `json:"abbreviation"`
	Offset        string         `json:"offset"`         // e.g., "-0500"
	OffsetSeconds int            `json:"offset_seconds"` // seconds from UTC
	IsDST         bool           `json:"is_dst"`
	Location      *time.Location `json:"-"` // Don't serialize this
}

TimezoneInfo contains detailed information about a timezone

type TimezoneProvider

type TimezoneProvider = types.TimezoneProvider

Type aliases for interfaces and types defined in types package

type ValidationIssue

type ValidationIssue = types.ValidationIssue

Type aliases for interfaces and types defined in types package

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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