Skip to content

Latest commit

 

History

18 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Go Reference

ical2struct

A minimal iCalendar / ICS parser for Golang.

The functions are the following two:

  1. Converting iCalendar / ICS text to a struct
  2. 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.

Install

go get github.com/v010maaa/ical2struct

Usage

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

Supported property

Please request, if we want to use more props.

Calender

Prop example
VERSION 2.0
CALSCALE GREGORIAN

Event

Prop example
DTSTART 20220224
DTEND 20220223
UID 1
SUMMARY Text text
DESCRIPTION text text

License

MIT

About

golang package to parse ical to json

Resources

Stars

3 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages