Documentation
¶
Overview ¶
Package ical parses iCalendar (.ics) files.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Encode ¶ added in v0.3.0
Encode writes the .ics file for cal into w.
Example ¶
package main import ( "os" "github.com/bounoable/ical" ) func main() { f, err := os.Open("/path/to/calendar.ics") if err != nil { panic(err) } defer f.Close() cal, err := ical.Parse(f) if err != nil { panic(err) } out, err := os.Create("/path/to/new_calendar.ics") if err != nil { panic(err) } if err := ical.Encode(cal, out); err != nil { panic(err) } }
Output:
Types ¶
type Calendar ¶
Calendar is a parsed iCalendar.
func Parse ¶
Parse parses the iCalendar from r.
Example ¶
package main import ( "fmt" "os" "github.com/bounoable/ical" ) func main() { f, err := os.Open("/path/to/calendar.ics") if err != nil { panic(err) } defer f.Close() cal, err := ical.Parse(f) if err != nil { panic(err) } // work with the events for _, evt := range cal.Events { fmt.Println(evt) } }
Output:
Example (ExplicitTimeLocation) ¶
package main import ( "fmt" "os" "time" "github.com/bounoable/ical" "github.com/bounoable/ical/parse" ) func main() { f, err := os.Open("/path/to/calendar.ics") if err != nil { panic(err) } defer f.Close() loc, err := time.LoadLocation("America/Los_Angeles") if err != nil { panic(err) } cal, err := ical.Parse(f, ical.ParseWith( parse.Location(loc), )) if err != nil { panic(err) } // work with the events for _, evt := range cal.Events { fmt.Println(evt) } }
Output:
Example (WithContext) ¶
package main import ( "context" "fmt" "os" "github.com/bounoable/ical" ) func main() { f, err := os.Open("/path/to/calendar.ics") if err != nil { panic(err) } defer f.Close() ctx := context.TODO() cal, err := ical.Parse(f, ical.Context(ctx)) if err != nil { panic(err) } // work with the events for _, evt := range cal.Events { fmt.Println(evt) } }
Output:
Example (WithLexerOptions) ¶
package main import ( "context" "fmt" "os" "github.com/bounoable/ical" "github.com/bounoable/ical/lex" ) func main() { f, err := os.Open("/path/to/calendar.ics") if err != nil { panic(err) } defer f.Close() lexContext := context.TODO() cal, err := ical.Parse(f, ical.LexWith( lex.Context(lexContext), lex.StrictLineBreaks, )) if err != nil { panic(err) } // work with the events for _, evt := range cal.Events { fmt.Println(evt) } }
Output:
Example (WithParserOptions) ¶
package main import ( "context" "fmt" "os" "time" "github.com/bounoable/ical" "github.com/bounoable/ical/parse" ) func main() { f, err := os.Open("/path/to/calendar.ics") if err != nil { panic(err) } defer f.Close() parseContext := context.TODO() cal, err := ical.Parse(f, ical.ParseWith( parse.Context(parseContext), parse.Location(time.Local), )) if err != nil { panic(err) } // work with the events for _, evt := range cal.Events { fmt.Println(evt) } }
Output:
Click to show internal directories.
Click to hide internal directories.