ics

package module
v0.0.0-...-e95e328 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2019 License: MIT Imports: 13 Imported by: 0

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 {
	// contains filtered or unexported fields
}

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) GetAlarmFunction

func (e *Event) GetAlarmFunction() func(*Event)

func (*Event) GetAlarmTime

func (e *Event) GetAlarmTime() time.Duration

func (*Event) GetAttendees

func (e *Event) GetAttendees() []*Attendee

func (*Event) GetCalendar

func (e *Event) GetCalendar() *Calendar

func (*Event) GetClass

func (e *Event) GetClass() string

func (*Event) GetCreated

func (e *Event) GetCreated() time.Time

func (*Event) GetDescription

func (e *Event) GetDescription() string

func (*Event) GetEnd

func (e *Event) GetEnd() time.Time

func (*Event) GetGeo

func (e *Event) GetGeo() *Geo

func (*Event) GetID

func (e *Event) GetID() string

func (*Event) GetImportedID

func (e *Event) GetImportedID() string

func (*Event) GetLastModified

func (e *Event) GetLastModified() time.Time

func (*Event) GetLocation

func (e *Event) GetLocation() string

func (*Event) GetOrganizer

func (e *Event) GetOrganizer() *Attendee

func (*Event) GetRRule

func (e *Event) GetRRule() string

func (*Event) GetSequence

func (e *Event) GetSequence() int

func (*Event) GetStart

func (e *Event) GetStart() time.Time

func (*Event) GetStatus

func (e *Event) GetStatus() string

func (*Event) GetSummary

func (e *Event) GetSummary() string

func (*Event) GetUrl

func (e *Event) GetUrl() string

func (*Event) GetWholeDayEvent

func (e *Event) GetWholeDayEvent() bool

func (*Event) IsWholeDay

func (e *Event) IsWholeDay() bool

func (*Event) SetAlarm

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

func (*Event) SetAttendee

func (e *Event) SetAttendee(a *Attendee) *Event

func (*Event) SetAttendees

func (e *Event) SetAttendees(attendees []*Attendee) *Event

func (*Event) SetCalendar

func (e *Event) SetCalendar(cal *Calendar) *Event

func (*Event) SetClass

func (e *Event) SetClass(class string) *Event

func (*Event) SetCreated

func (e *Event) SetCreated(created time.Time) *Event

func (*Event) SetDescription

func (e *Event) SetDescription(description string) *Event

func (*Event) SetEnd

func (e *Event) SetEnd(end time.Time) *Event

func (*Event) SetGeo

func (e *Event) SetGeo(geo *Geo) *Event

func (*Event) SetID

func (e *Event) SetID(id string) *Event

func (*Event) SetImportedID

func (e *Event) SetImportedID(id string) *Event

func (*Event) SetLastModified

func (e *Event) SetLastModified(modified time.Time) *Event

func (*Event) SetLocation

func (e *Event) SetLocation(location string) *Event

func (*Event) SetOrganizer

func (e *Event) SetOrganizer(a *Attendee) *Event

func (*Event) SetRRule

func (e *Event) SetRRule(rrule string) *Event

func (*Event) SetSequence

func (e *Event) SetSequence(sq int) *Event

func (*Event) SetStart

func (e *Event) SetStart(start time.Time) *Event

func (*Event) SetStatus

func (e *Event) SetStatus(status string) *Event

func (*Event) SetSummary

func (e *Event) SetSummary(summary string) *Event

func (*Event) SetUrl

func (e *Event) SetUrl(url string) *Event

func (*Event) SetWholeDayEvent

func (e *Event) SetWholeDayEvent(wholeDay bool) *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 Geo

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

Geo has latitude and longitude from the the GEO property of an event

func NewGeo

func NewGeo(lat string, long string) *Geo

NewGeo creates a new Geo object

func (*Geo) Latitude

func (g *Geo) Latitude() (float64, error)

Latitude returns the latitude value from Geo

func (*Geo) Longitude

func (g *Geo) Longitude() (float64, error)

Longitude returns the longitude value from Geo

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