ics - examples_test.go
1 package ics_test
2
3 import (
4 "fmt"
5 "strings"
6
7 "vimagination.zapto.org/ics"
8 )
9
10 func Example() {
11 const icsData = "BEGIN:VCALENDAR\r\n" +
12 "VERSION:2.0\r\n" +
13 "PRODID:-//hacksw/handcal//NONSGML v1.0//EN\r\n" +
14 "BEGIN:VEVENT\r\n" +
15 "UID:uid1@example.com\r\n" +
16 "ORGANIZER;CN=John Doe:MAILTO:john.doe@example.com\r\n" +
17 "DTSTAMP:19970701T100000Z\r\n" +
18 "DTSTART:19970714T170000Z\r\n" +
19 "DTEND:19970715T040000Z\r\n" +
20 "SUMMARY:Bastille Day Party\r\n" +
21 "GEO:48.85299;2.36885\r\n" +
22 "END:VEVENT\r\n" +
23 "END:VCALENDAR"
24
25 cal, err := ics.Decode(strings.NewReader(icsData))
26 if err != nil {
27 fmt.Println("Error: ", err)
28
29 return
30 }
31
32 fmt.Println(cal.Event[0].DateTimeStart.DateTime.Time, "-", cal.Event[0].Summary.Text)
33
34 // Output:
35 // 1997-07-14 17:00:00 +0000 UTC - Bastille Day Party
36 }
37