Mercurial > code > home > repos > gcalendarwatch
comparison calsync/convert/convert.go @ 49:2991c1166852
start calsync in go. Calendar list seems to sync
author | drewp@bigasterisk.com |
---|---|
date | Mon, 19 Aug 2024 13:25:03 -0700 |
parents | |
children | a9b720445bcf |
comparison
equal
deleted
inserted
replaced
48:f2dd88b9964c | 49:2991c1166852 |
---|---|
1 package convert | |
2 | |
3 import ( | |
4 "net/url" | |
5 "time" | |
6 | |
7 "bigasterisk.com/go/gcalendarwatch/gcalclient" | |
8 "bigasterisk.com/go/gcalendarwatch/mongoclient" | |
9 "google.golang.org/api/calendar/v3" | |
10 ) | |
11 | |
12 func MongoCalFromGoogleCal(cal *calendar.CalendarListEntry) mongoclient.MongoCal { | |
13 return mongoclient.MongoCal{ | |
14 Url: gcalclient.MakeCalUrl(cal.Id), | |
15 GoogleId: cal.Id, | |
16 Summary: cal.Summary, | |
17 Description: cal.Description, | |
18 } | |
19 } | |
20 | |
21 func MakeEventUrl(calUrl string, evId string) string { | |
22 return calUrl + "/" + url.QueryEscape(evId) | |
23 } | |
24 | |
25 func MakeEventUrl2(cal mongoclient.MongoCal, evId string) string { | |
26 return MakeEventUrl3(cal.GoogleId, evId) | |
27 } | |
28 | |
29 func MakeEventUrl3(googleCalId string, evId string) string { | |
30 return MakeEventUrl("http://bigasterisk.com/calendar/"+ | |
31 url.QueryEscape(googleCalId), evId) | |
32 } | |
33 | |
34 func MongoEventFromGoogleEvent2( | |
35 calUrl string, | |
36 ev *gcalclient.CalendarEvent, | |
37 now time.Time, | |
38 ) mongoclient.MongoEvent { | |
39 return mongoEventFromGoogleEvent(calUrl, ev, now) | |
40 | |
41 } | |
42 func MongoEventFromGoogleEvent( | |
43 cal *calendar.CalendarListEntry, | |
44 ev *gcalclient.CalendarEvent, | |
45 now time.Time, | |
46 ) mongoclient.MongoEvent { | |
47 return mongoEventFromGoogleEvent(MakeEventUrl3(cal.Id, ev.Id), ev, now) | |
48 } | |
49 | |
50 func mongoEventFromGoogleEvent(calUrl string, ev *gcalclient.CalendarEvent, now time.Time) mongoclient.MongoEvent { | |
51 return mongoclient.MongoEvent{ | |
52 Url: calUrl, | |
53 GoogleId: ev.Event.Id, | |
54 HtmlLink: ev.HtmlLink, | |
55 Title: ev.Summary, //? | |
56 // FeedId : ev.Event.FeedId, // or calid? | |
57 // FeedTitle : ev.Event.FeedTitle, // /or what | |
58 EndTimeUnspecified: ev.Event.EndTimeUnspecified, | |
59 // Start : ev.Start.DateTime, | |
60 // StartDate : ev.Event.StartDate, | |
61 // StartTime : ev.Event.StartTime, | |
62 // End : ev.Event.End, | |
63 // EndDate : ev.Event.EndDate, | |
64 // EndTime : ev.Event.EndTime, | |
65 LastUpdated: now, | |
66 } | |
67 | |
68 } |