calendar

package
v0.3.25 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2026 License: MIT Imports: 15 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package calendar reads vdir calendars (one iCalendar file per event, as vdirsyncer and khal keep them), expands their events for a month, and fires their reminders. It never touches the network: syncing is left to the tool that fills the directories.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Parse

func Parse(data string, local *time.Location) ([]Event, []Skip, error)

Parse reads an iCalendar document's events, interpreting dates and floating times in local. A document that is not well-formed is an error; an event using something unsupported is left out and listed in the skips.

Types

type Alarm

type Alarm struct {
	Offset   time.Duration
	FromEnd  bool
	At       time.Time
	Absolute bool
}

Alarm is one VALARM: a trigger relative to the event's start (or its end), or at a fixed time.

type Clock

type Clock interface {
	Now() time.Time
	AfterFunc(d time.Duration, fn func()) (stop func() bool)
}

Clock is the time source reminders are scheduled on.

var WallClock Clock = wallClock{}

WallClock is the real clock.

type Event

type Event struct {
	UID      string
	Summary  string
	Location string
	Start    time.Time
	End      time.Time
	AllDay   bool
	Alarms   []Alarm
	// contains filtered or unexported fields
}

Event is one VEVENT: a single event, or the series an RRULE expands.

type Month

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

Month is a month's occurrences by day of the month.

func (*Month) Day

func (m *Month) Day(d int) []Occurrence

Day lists day d's occurrences: all-day ones first, then by start.

type Occurrence

type Occurrence struct {
	Summary  string
	Location string
	Start    time.Time
	End      time.Time
	AllDay   bool
	Color    string
}

Occurrence is one instance of an event, in the store's location.

type Reminder

type Reminder struct {
	Occurrence
	At time.Time
}

Reminder is an alarm of an occurrence coming due.

type Skip

type Skip struct {
	UID    string
	Reason string
}

Skip is an event Parse left out, and why.

type Source

type Source struct {
	Dir   string
	Color string
}

Source is one vdir directory of .ics files and the color its events wear.

type Store

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

Store holds the events of the configured vdir directories, follows their changes, expands them per month on demand, and keeps each expansion until a file changes.

func NewStore

func NewStore(clock Clock, loc *time.Location) *Store

NewStore is an empty store reading times in loc and scheduling reminders on clock.

func (*Store) Changes

func (s *Store) Changes() (<-chan struct{}, func())

Changes ticks after every change of the events; stop ends the feed.

func (*Store) Close

func (s *Store) Close()

Close stops following the directories and the reminders.

func (*Store) Configure

func (s *Store) Configure(sources []Source) error

Configure replaces the sources: every .ics file under each directory is read and the directories are watched. A directory that cannot be read or watched is reported and left out; the others still load.

func (*Store) Configured

func (s *Store) Configured() bool

Configured reports whether any source is configured.

func (*Store) Month

func (s *Store) Month(year int, month time.Month) *Month

Month returns the occurrences of year's month, expanding them once until the files change.

func (*Store) Next

func (s *Store) Next(now time.Time) (Occurrence, bool)

Next is the first timed occurrence starting at now or later, within a week.

func (*Store) RunReminders

func (s *Store) RunReminders(notify func(Reminder))

RunReminders fires notify for every alarm coming due from now on, one timer to the next alarm, until Close. A change of the files reschedules it.

Jump to

Keyboard shortcuts

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