-
Notifications
You must be signed in to change notification settings - Fork 0
/
events.go
55 lines (51 loc) · 1.71 KB
/
events.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package main
import (
"fmt"
"log"
"time"
)
func GetEvents() {
srv, err := GetCalendarSerivce()
if err != nil {
log.Fatalf("Unable to retrieve Calendar client: %v", err)
}
t := time.Now().Format(time.RFC3339)
cl, _ := srv.CalendarList.List().Do()
for _, item := range cl.Items {
fmt.Printf("====> %v\n\n", item.Summary)
fmt.Println("Upcoming events:")
events, err := srv.Events.List(item.Id).ShowDeleted(false).
SingleEvents(true).TimeMin(t).MaxResults(10).OrderBy("startTime").Do()
if err != nil {
log.Fatalf("Unable to retrieve next ten of the user's events: %v", err)
}
if len(events.Items) == 0 {
fmt.Println("No upcoming events found.")
} else {
for _, eventItem := range events.Items {
date := eventItem.Start.DateTime
if date == "" {
date = eventItem.Start.Date
}
fmt.Printf("%v on %v \n\n", eventItem.Summary, date)
}
}
}
// events, err := srv.Events.List("planing").ShowDeleted(false).
// SingleEvents(true).TimeMin(t).MaxResults(20).OrderBy("startTime").Do()
// if err != nil {
// log.Fatalf("Unable to retrieve next ten of the user's events: %v", err)
// }
// fmt.Println("Upcoming events:")
// if len(events.Items) == 0 {
// fmt.Println("No upcoming events found.")
// } else {
// for _, item := range cl.Items {
// date := item.Start.DateTime
// if date == "" {
// date = item.Start.Date
// }
// fmt.Printf("%v (%v)\n", item.Summary, date)
// }
// }
}