ics

package module
v0.0.0-...-02c2eda Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2020 License: MIT Imports: 7 Imported by: 1

README

ics

This is a simple module to generate iCalendar (ics) files. The API is subject to change. Currently supports VCALENDAR and VEVENT.

Example program

import (
    "github.com/anders/ics"
)

func main() {
    cal := ics.NewCalendar()
    cal.Add(ics.Event{
        "DTSTART": time.Now(),
        "DTEND": time.Now().Add(45*time.Minute),
        "SUMMARY": "Hello World",
    })
    cal.Encode(os.Stdout)
}

output:

BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//github.com/anders/ics
CALSCAL:GREGORIAN
BEGIN:VEVENT
DTEND:20200127T191212Z
DTSTART:20200127T182712Z
SUMMARY:Hello World
END:VEVENT
END:VCALENDAR

Documentation

Overview

Package ics provides a simple iCalendar encoder.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Calendar

type Calendar struct {
	Properties map[string]interface{} // VCALENDAR fields
	Events     []Event                // a list of Events
}

Calendar holds a list of Events.

func NewCalendar

func NewCalendar() *Calendar

NewCalendar returns a new instance of Calendar with some properties preset.

func (*Calendar) Add

func (c *Calendar) Add(obj interface{}) error

Add adds an object to the calendar.

func (Calendar) Encode

func (cal Calendar) Encode(w io.Writer) error

Encode writes a complete calendar to the specified writer.

func (*Calendar) Get

func (c *Calendar) Get(key string) interface{}

Get returns a property.

func (*Calendar) Set

func (c *Calendar) Set(key string, value interface{})

Set sets a VCALENDAR property.

type Event

type Event map[string]interface{}

Event is a single calendar entry. Supported types are strings.Stringer, string and time.Time.

func (Event) Encode

func (ev Event) Encode(w io.Writer) error

Encode writes a single event to the specified Writer. Supported values are strings and time.Time, as well as any time that conforms to the Stringer interface.

Jump to

Keyboard shortcuts

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