ics

package module
v0.0.0-...-4f524b8 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2017 License: MIT Imports: 13 Imported by: 2

README

ics-golang

Golang ics parser

Installation

go get github.com/PuloV/ics-golang

How to use it

  • Import the package:
import (
	"github.com/PuloV/ics-golang"
)
  • Create a new parser:
    parser := ics.New()
  • Pass as many ics urls as you want to the input chan :
    parserChan := parser.GetInputChan()
    parserChan <- "http://www.google.com/calendar/ical/bg.bulgarian%23holiday%40group.v.calendar.google.com/public/basic.ics"
    parserChan <- "http://www.google.com/calendar/ical/en.bulgarian%23holiday%40group.v.calendar.google.com/public/basic.ics"
    parserChan <- "http://www.google.com/calendar/ical/de.bulgarian%23holiday%40group.v.calendar.google.com/public/basic.ics"
* don't rely that the calendars will be parsed in this order
  • Wait for the result of the parsing :

    outputChan := parser.GetOutputChan()
    //  print events
	go func() {
		for event := range outputChan {
			fmt.Println(event.GetImportedID())
		}
	}()

	// wait to kill the main goroute
	parser.Wait()
* the data form the calendars may be mixed

Different usage

You can see diferent usage in the ics-golang-examples or in the test files <filename>_test.go

LICENCE

The MIT License (MIT)

Copyright (c) 2014 Йордан Пулов

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Documentation

Index

Constants

View Source
const IcsFormat = "20060102T150405Z"

ics date time format

View Source
const IcsFormatWholeDay = "20060102"

ics date format ( describes a whole day)

View Source
const YmdHis = "2006-01-02 15:04:05"

Y-m-d H:i:S time format

Variables

View Source
var DeleteTempFiles bool

if DeleteTempFiles is true , after we download ics and parse it , the local temp file will be deleted

View Source
var FilePath string

Describes the file path to the folder with the temp ics files

View Source
var MaxRepeats int

max of the rrule repeat for single event

View Source
var RepeatRuleApply bool

if RepeatRuleApply is true , the rrule will create new objects for the repeated events

Functions

This section is empty.

Types

type Attendee

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

func NewAttendee

func NewAttendee() *Attendee

func (*Attendee) GetEmail

func (a *Attendee) GetEmail() string

func (*Attendee) GetName

func (a *Attendee) GetName() string

func (*Attendee) GetRole

func (a *Attendee) GetRole() string

func (*Attendee) GetStatus

func (a *Attendee) GetStatus() string

func (*Attendee) GetType

func (a *Attendee) GetType() string

func (*Attendee) SetEmail

func (a *Attendee) SetEmail(e string) *Attendee

func (*Attendee) SetName

func (a *Attendee) SetName(n string) *Attendee

func (*Attendee) SetRole

func (a *Attendee) SetRole(r string) *Attendee

func (*Attendee) SetStatus

func (a *Attendee) SetStatus(s string) *Attendee

func (*Attendee) SetType

func (a *Attendee) SetType(ct string) *Attendee

func (*Attendee) String

func (a *Attendee) String() string

type Calendar

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

func NewCalendar

func NewCalendar() *Calendar

func (*Calendar) GetDesc

func (c *Calendar) GetDesc() string

func (*Calendar) GetEventByID

func (c *Calendar) GetEventByID(eventID string) (*Event, error)

get event by id

func (*Calendar) GetEventByImportedID

func (c *Calendar) GetEventByImportedID(eventID string) (*Event, error)

get event by imported id

func (*Calendar) GetEvents

func (c *Calendar) GetEvents() []Event

get all events in the calendar

func (*Calendar) GetEventsByDate

func (c *Calendar) GetEventsByDate(dateTime time.Time) ([]*Event, error)

get all events for specified date

func (*Calendar) GetEventsByDates

func (c *Calendar) GetEventsByDates() map[string][]*Event

get all events in the calendar ordered by date

func (*Calendar) GetName

func (c *Calendar) GetName() string

func (*Calendar) GetTimezone

func (c *Calendar) GetTimezone() time.Location

func (*Calendar) GetUpcomingEvents

func (c *Calendar) GetUpcomingEvents(n int) []Event

GetUpcomingEvents returns the next n-Events.

func (*Calendar) GetUrl

func (c *Calendar) GetUrl() string

func (*Calendar) GetVersion

func (c *Calendar) GetVersion() float64

func (*Calendar) SetDesc

func (c *Calendar) SetDesc(desc string) *Calendar

func (*Calendar) SetEvent

func (c *Calendar) SetEvent(event Event) (*Calendar, error)

add event to the calendar

func (*Calendar) SetName

func (c *Calendar) SetName(n string) *Calendar

func (*Calendar) SetTimezone

func (c *Calendar) SetTimezone(tz time.Location) *Calendar

func (*Calendar) SetUrl

func (c *Calendar) SetUrl(u string) *Calendar

func (*Calendar) SetVersion

func (c *Calendar) SetVersion(ver float64) *Calendar

func (*Calendar) String

func (c *Calendar) String() string

type Event

type Event struct {
	Start         time.Time     `json:"start"`
	End           time.Time     `json:"end"`
	Created       time.Time     `json:"created"`
	Modified      time.Time     `json:"modified"`
	AlarmTime     time.Duration `json:"alarmTime"`
	ImportedID    string        `json:"importedID"`
	Status        string        `json:"status"`
	Description   string        `json:"description"`
	Location      string        `json:"location"`
	Summary       string        `json:"summary"`
	RRule         string        `json:"rrule"`
	Class         string        `json:"class"`
	ID            string        `json:"id"`
	Sequence      int           `json:"sequence"`
	WholeDayEvent bool          `json:"wholeDayEvent"`
	Attendees     []*Attendee   `json:"-"`
	Organizer     *Attendee     `json:"-"`
	InCalendar    *Calendar     `json:"-"`
	AlarmCallback func(*Event)  `json:"-"`
}

func NewEvent

func NewEvent() *Event

func (*Event) Clone

func (e *Event) Clone() *Event

func (*Event) GenerateEventId

func (e *Event) GenerateEventId() string

generates an unique id for the event

func (*Event) SetAlarm

func (e *Event) SetAlarm(alarmAfter time.Duration, callback func(*Event)) *Event

func (*Event) String

func (e *Event) String() string

type Events

type Events []Event

func (Events) Len

func (events Events) Len() int

func (Events) Less

func (events Events) Less(i, j int) bool

func (Events) Swap

func (events Events) Swap(i, j int)

type Parser

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

func New

func New() *Parser

creates new parser

func (*Parser) Done

func (p *Parser) Done() bool

is everything is parsed

func (*Parser) GetCalendars

func (p *Parser) GetCalendars() ([]*Calendar, error)

returns the chan where will be received events

func (*Parser) GetErrors

func (p *Parser) GetErrors() ([]error, error)

returns the array with the errors occurred while parsing the events

func (*Parser) GetInputChan

func (p *Parser) GetInputChan() chan string

returns the chan for calendar urls

func (*Parser) GetOutputChan

func (p *Parser) GetOutputChan() chan *Event

returns the chan where will be received events

func (*Parser) Load

func (p *Parser) Load(iCalContent string)

Load calender from content

func (*Parser) Wait

func (p *Parser) Wait()

wait until everything is parsed

Jump to

Keyboard shortcuts

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