A minimal iCalendar / ICS parser for Golang.
The functions are the following two:
- Converting iCalendar / ICS text to a struct
- Converting a struct to an ics format
Since this is a project that started the other day, we are looking for friends who will contribute to this project.
go get github.com/v010maaa/ical2struct
event_list := []models.Event{
{
DateStart: "20220223",
DateEnd: "20220224",
Uid: "1",
Description: "English Class",
Summary: "English (not available)",
},
{
DateStart: "20220228",
DateEnd: "20220301",
Uid: "2",
Description: "Japanese",
Summary: "Japanese (reserved)",
},
}
text := ics.ComposeIcs(event_list)
fmt.Println(text)text := `BEGIN:VCALENDAR
VERSION:2.0
CALSCALE:GREGORIAN
BEGIN:VEVENT
DTEND;VALUE=20220224
DTSTART;VALUE=20220223
UID:1
DESCRIPTION:English Class
SUMMARY:English (not available)
END:VEVENT
BEGIN:VEVENT
DTEND;VALUE=20220301
DTSTART;VALUE=20220228
UID:2
DESCRIPTION:Japanese
SUMMARY:Japanese (reserved)
END:VEVENT
END:VCALENDAR`
calendar := ics.ParseIcs(text)
fmt.Printf(calendar.Calscale)type Calendar struct {
Version string
Calscale string
Events []Event
}
type Event struct {
DateStart string
DateEnd string
Uid string
Description string
Summary string
}Please check some example here
Please request, if we want to use more props.
| Prop | example |
|---|---|
| VERSION | 2.0 |
| CALSCALE | GREGORIAN |
| Prop | example |
|---|---|
| DTSTART | 20220224 |
| DTEND | 20220223 |
| UID | 1 |
| SUMMARY | Text text |
| DESCRIPTION | text text |