From aacd6faba0731df34dd47a3f315004f0740e5a8c Mon Sep 17 00:00:00 2001 From: "Glenn Y. Rolland" Date: Fri, 25 Jun 2021 14:46:25 +0200 Subject: [PATCH] Add basic operations --- cmd/kiwimix/main.go | 39 +++++++++++++++++++++++++++ pkg/kiwimix/{main.go => intersect.go} | 0 pkg/kiwimix/substract.go | 0 pkg/kiwimix/union.go | 0 pkg/kiwimix/version.go | 1 + 5 files changed, 40 insertions(+) rename pkg/kiwimix/{main.go => intersect.go} (100%) create mode 100644 pkg/kiwimix/substract.go create mode 100644 pkg/kiwimix/union.go create mode 100644 pkg/kiwimix/version.go diff --git a/cmd/kiwimix/main.go b/cmd/kiwimix/main.go index e69de29..91dba43 100644 --- a/cmd/kiwimix/main.go +++ b/cmd/kiwimix/main.go @@ -0,0 +1,39 @@ +package main + +import ( + "fmt" + "io/ioutil" + + ics "github.com/PuloV/ics-golang" + _ "github.com/mattn/go-sqlite3/driver" +) + +func assertOk(e error) { + if e != nil { + panic(e) + } +} + +func main() { + fmt.Println("Hello world") + + icsBytes, err := ioutil.ReadFile("example.ics") + assertOk(err) + + // start, end := time.Now(), time.Now().Add(12*30*24*time.Hour) + parser := ics.New() + + parser.Load(string(icsBytes)) + _, err = parser.GetErrors() + assertOk(err) + + calendars, err := parser.GetCalendars() + assertOk(err) + + events := calendars[0].GetEvents() + for _, e := range events { + fmt.Printf("%#v\n", e) + // fmt.Printf("%s on %s by %s\n", e.Summary, e.Start, e.Organizer.Cn) + } + // fmt.Print(string(f)) +} diff --git a/pkg/kiwimix/main.go b/pkg/kiwimix/intersect.go similarity index 100% rename from pkg/kiwimix/main.go rename to pkg/kiwimix/intersect.go diff --git a/pkg/kiwimix/substract.go b/pkg/kiwimix/substract.go new file mode 100644 index 0000000..e69de29 diff --git a/pkg/kiwimix/union.go b/pkg/kiwimix/union.go new file mode 100644 index 0000000..e69de29 diff --git a/pkg/kiwimix/version.go b/pkg/kiwimix/version.go new file mode 100644 index 0000000..afe6c69 --- /dev/null +++ b/pkg/kiwimix/version.go @@ -0,0 +1 @@ +package kiwimix