Documentation
¶
Overview ¶
Package ical2 provides a data model for the iCalendar specification. Marshalling to the textual iCalendar ics format is implemented. Unmarshalling is not currently supported.
See https://tools.ietf.org/html/rfc5545 https://tools.ietf.org/html/rfc6868 https://tools.ietf.org/html/rfc7986.
Availability (https://tools.ietf.org/html/rfc7953) is not supported.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Extension ¶
Extension is a key/value struct for any additional non-standard or unsupported calendar properties.
type VAlarm ¶
type VAlarm interface { VComponent IsAlarm() }
VAlarm is an alarm component.
Example (Audio) ¶
package main import ( "fmt" "github.com/rickb777/ical2" "github.com/rickb777/ical2/parameter" "github.com/rickb777/ical2/value" "time" ) func main() { const tz = "Europe/Paris" zone, _ := time.LoadLocation(tz) dt := time.Date(2014, time.Month(1), 1, 7, 0, 0, 0, zone) ds := dt.Add(time.Hour) de := ds.Add(5 * time.Hour) alarm := &ical2.VAudioAlarm{ Trigger: value.DateTime(ds.Add(-time.Hour).In(time.UTC)), Duration: value.Duration("PT10M"), Repeat: value.Integer(3), Attach: value.URI("http://example.com/clips/poke.aud"). With(parameter.FmtType("audio/basic")), } event := &ical2.VEvent{ UID: value.Text("123"), DTStamp: value.TStamp(dt), Start: value.DateTime(ds).With(parameter.TZid(tz)), End: value.DateTime(de).With(parameter.TZid(tz)), Status: value.NeedsAction(), Alarm: []ical2.VAlarm{alarm}, } c := ical2.NewVCalendar("-//My App//Event Calendar//EN").With(event) // usually you'd Encode to some io.Writer //c.Encode(w) // but for this example, we'll just stringify fmt.Println(c.String()) }
Output: BEGIN:VCALENDAR PRODID:-//My App//Event Calendar//EN VERSION:2.0 CALSCALE:GREGORIAN BEGIN:VEVENT DTSTART;VALUE=DATE-TIME;TZID=Europe/Paris:20140101T080000 DTEND;VALUE=DATE-TIME;TZID=Europe/Paris:20140101T130000 DTSTAMP:20140101T060000Z UID:123 STATUS:NEEDS-ACTION BEGIN:VALARM ACTION:AUDIO TRIGGER;VALUE=DATE-TIME:20140101T060000Z DURATION;VALUE=DURATION:PT10M REPEAT;VALUE=INTEGER:3 ATTACH;VALUE=URI;FMTTYPE=audio/basic:http://example.com/clips/poke.aud END:VALARM END:VEVENT END:VCALENDAR
Example (Display) ¶
package main import ( "fmt" "github.com/rickb777/ical2" "github.com/rickb777/ical2/value" "time" ) func main() { dt := time.Date(2014, time.Month(1), 1, 7, 0, 0, 0, time.UTC) ds := dt.Add(time.Hour) de := ds.Add(5 * time.Hour) alarm := &ical2.VDisplayAlarm{ Description: value.Text("Wakey wakey"), Trigger: value.Duration("-PT10M"), } event := &ical2.VEvent{ UID: value.Text("123"), DTStamp: value.TStamp(dt), Start: value.DateTime(ds), End: value.DateTime(de), Alarm: []ical2.VAlarm{alarm}, } c := ical2.NewVCalendar("-//My App//Event Calendar//EN").With(event) // usually you'd Encode to some io.Writer //c.Encode(w) // but for this example, we'll just stringify fmt.Println(c.String()) }
Output: BEGIN:VCALENDAR PRODID:-//My App//Event Calendar//EN VERSION:2.0 CALSCALE:GREGORIAN BEGIN:VEVENT DTSTART;VALUE=DATE-TIME:20140101T080000Z DTEND;VALUE=DATE-TIME:20140101T130000Z DTSTAMP:20140101T070000Z UID:123 BEGIN:VALARM ACTION:DISPLAY DESCRIPTION:Wakey wakey TRIGGER;VALUE=DURATION:-PT10M END:VALARM END:VEVENT END:VCALENDAR
Example (Email) ¶
package main import ( "fmt" "github.com/rickb777/ical2" "github.com/rickb777/ical2/parameter" "github.com/rickb777/ical2/value" "time" ) func main() { const tz = "Europe/Paris" zone, _ := time.LoadLocation(tz) dt := time.Date(2014, time.Month(1), 1, 7, 0, 0, 0, zone) ds := dt.Add(time.Hour) de := ds.Add(5 * time.Hour) alarm := &ical2.VEmailAlarm{ Description: value.Text("Wakey wakey"), Trigger: value.Duration("-PT10M"), Summary: value.Text("There are things to be done."), Attendee: []value.URIValue{value.CalAddress("john_public@example.com")}, } event := &ical2.VEvent{ UID: value.Text("123"), DTStamp: value.TStamp(dt), Start: value.DateTime(ds).With(parameter.TZid(tz)), End: value.DateTime(de).With(parameter.TZid(tz)), Alarm: []ical2.VAlarm{alarm}, } c := ical2.NewVCalendar("-//My App//Event Calendar//EN").With(event) // usually you'd Encode to some io.Writer //c.Encode(w) // but for this example, we'll just stringify fmt.Println(c.String()) }
Output: BEGIN:VCALENDAR PRODID:-//My App//Event Calendar//EN VERSION:2.0 CALSCALE:GREGORIAN BEGIN:VEVENT DTSTART;VALUE=DATE-TIME;TZID=Europe/Paris:20140101T080000 DTEND;VALUE=DATE-TIME;TZID=Europe/Paris:20140101T130000 DTSTAMP:20140101T060000Z UID:123 BEGIN:VALARM ACTION:EMAIL DESCRIPTION:Wakey wakey TRIGGER;VALUE=DURATION:-PT10M SUMMARY:There are things to be done. ATTENDEE:mailto:john_public@example.com END:VALARM END:VEVENT END:VCALENDAR
type VAudioAlarm ¶
type VAudioAlarm struct { Trigger value.Trigger // required Duration value.DurationValue Repeat value.IntegerValue Attach value.Attachable // optional }
VAudioAlarm captures a calendar event
func (*VAudioAlarm) EncodeIcal ¶
EncodeIcal serialises the event to the buffer in iCalendar ics format
type VCalendar ¶
type VCalendar struct { // RFC-5545 properties Version value.TextValue // 2.0 ProdId value.TextValue // -//My Company//NONSGML Event Calendar//EN Method value.TextValue // PUBLISH, REQUEST, CalScale value.TextValue // GREGORIAN // RFC-7986 properties Name value.TextValue // My Calendar Name Description value.TextValue // A description of my calendar URL value.TextValue // http://my.calendar/url LastModified value.DateTimeValue // can also be specified per VComponent RecurrenceId value.DateTimeValue RefreshInterval value.DurationValue // PT12H Color value.TextValue // CSS3 color name //X_WR_CALNAME string // My Calendar Name //X_WR_CALDESC string // A description of my calendar //X_WR_TIMEZONE string // Europe/London //X_PUBLISHED_TTL string // PT12H Extensions []Extension VComponent []VComponent }
VCalendar is a calendar as per RFC-5545 https://tools.ietf.org/html/rfc5545.
func NewVCalendar ¶
NewVCalendar constructs a new VCalendar with the required properties set. The version is set to 2.0 and the calendar scale is Gregorian.
func (*VCalendar) Encode ¶
Encode encodes the calendar in ICS format, writing it to some Writer. The line endings are "\r\n" for normal iCalendar transmission purposes.
func (*VCalendar) EncodePlain ¶
EncodePlain encodes the calendar in ICS format, writing it to some Writer. The line ending are "\n" for non-transmission purposes, e.g. for viewing.
func (*VCalendar) Extend ¶
Extend adds an extension property to the calendar. The VCalendar modified and is returned.
func (*VCalendar) String ¶
String returns the ICS formatted content, albeit using "\n" line endings.
func (*VCalendar) With ¶
func (c *VCalendar) With(component VComponent) *VCalendar
With associates a component with the calendar. The VCalendar modified and is returned.
type VComponent ¶
VComponent is an item that belongs to a calendar.
type VDisplayAlarm ¶
type VDisplayAlarm struct { Description value.TextValue // required Trigger value.Trigger // required Duration value.DurationValue Repeat value.IntegerValue }
VDisplayAlarm captures a calendar event
func (*VDisplayAlarm) EncodeIcal ¶
EncodeIcal serialises the event to the buffer in iCalendar ics format
type VEmailAlarm ¶
type VEmailAlarm struct { Description value.TextValue // required Trigger value.Trigger // required Summary value.TextValue // required Attendee []value.URIValue // required one or more Duration value.DurationValue Repeat value.IntegerValue Attach []value.Attachable // optional }
VEmailAlarm captures a calendar event
func (*VEmailAlarm) EncodeIcal ¶
EncodeIcal serialises the event to the buffer in iCalendar ics format
type VEvent ¶
type VEvent struct { // Start specifies when the calendar component begins. // https://tools.ietf.org/html/rfc5545#section-3.8.2.4 Start value.DateTimeValue // End specifies when the calendar component ends, which must be after the start. // Use either End or Duration but not both. // https://tools.ietf.org/html/rfc5545#section-3.8.2.2 End value.DateTimeValue // Duration specifies a positive duration of time. // Use either End or Duration but not both. // https://tools.ietf.org/html/rfc5545#section-3.8.2.5 Duration value.DurationValue // Created specifies the date and time that the calendar information was // created by the calendar user agent in the calendar store. This is // analogous to the creation date and time for a file in the file system. // https://tools.ietf.org/html/rfc5545#section-3.8.7.1 Created value.DateTimeValue // DTStamp: in the case of an iCalendar object that specifies a // "METHOD" property, this property specifies the date and time that // the instance of the iCalendar object was created. In the case of // an iCalendar object that doesn't specify a "METHOD" property, this // property specifies the date and time that the information // associated with the calendar component was last revised in the // calendar store. // https://tools.ietf.org/html/rfc5545#section-3.8.7.2 DTStamp value.DateTimeValue // LastModified specifies the date and time that the information associated // with the calendar component was last revised in the calendar store. // This is analogous to the modification date and time for a file in the // file system. // https://tools.ietf.org/html/rfc5545#section-3.8.7.3 LastModified value.DateTimeValue // ExceptionDate defines the list of DATE-TIME exceptions for recurring events, // to-dos, journal entries, or time zone definitions. // https://tools.ietf.org/html/rfc5545#section-3.8.5.1 ExceptionDate []value.DateTimeValue // RecurrenceDate defines the list of DATE-TIME values for recurring events, // to-dos, journal entries, or time zone definitions. // https://tools.ietf.org/html/rfc5545#section-3.8.5.2 RecurrenceDate []value.Temporal // DateTime or Period // RecurrenceRule defines a rule or repeating pattern for recurring events, // to-dos, journal entries, or time zone definitions. // https://tools.ietf.org/html/rfc5545#section-3.8.5.3 RecurrenceRule value.RecurrenceValue // RecurrenceId is used in conjunction with the "UID" and // "SEQUENCE" properties to identify a specific instance of a // recurring "VEVENT", "VTODO", or "VJOURNAL" calendar component. // The property value is the original value of the "DTSTART" property // of the recurrence instance. // https://tools.ietf.org/html/rfc5545#section-3.8.4.4 RecurrenceId value.DateTimeValue // Conference specifies information for accessing a conferencing system. // https://tools.ietf.org/html/rfc7986#section-5.11 Conference []value.URIValue // Attendee defines the attendee(s) within the calendar component. // https://tools.ietf.org/html/rfc5545#section-3.8.4.1 Attendee []value.URIValue // Organizer defines the organizer for the calendar component. // https://tools.ietf.org/html/rfc5545#section-3.8.4.3 Organizer value.URIValue // Contact is used to represent contact information or alternately a reference to contact information // associated with the calendar component. // https://tools.ietf.org/html/rfc5545#section-3.8.4.2 Contact []value.TextValue // https://tools.ietf.org/html/rfc5545#section-3.8.1.12 Summary value.TextValue // Description provides a more complete description of the calendar component than // that provided by the "SUMMARY" property. // https://tools.ietf.org/html/rfc5545#section-3.8.1.5 Description value.TextValue // Class defines the access classification for the calendar component. // https://tools.ietf.org/html/rfc5545#section-3.8.1.3 Class value.TextValue // PUBLIC, PRIVATE, CONFIDENTIAL, etc // Comment provides non-processing information intended as a comment to the calendar user. // https://tools.ietf.org/html/rfc5545#section-3.8.1.4 Comment []value.TextValue // RelatedTo is used to represent a relationship or reference between one calendar // component and another. It consists of the persistent, globally unique identifier // of another calendar component. This value would be represented in a calendar // component by the "UID" property. // https://tools.ietf.org/html/rfc5545#section-3.8.4.5 RelatedTo value.TextValue // URL defines a Uniform Resource Locator (URL) associated with the iCalendar object. // This implementation always includes the "VALUE=URI" parameter, although some others // do not. // https://tools.ietf.org/html/rfc5545#section-3.8.4.6 URL value.URIValue // UID defines the persistent, globally unique identifier for the calendar component. // https://tools.ietf.org/html/rfc5545#section-3.8.4.7 UID value.TextValue // Categories specify categories or subtypes of the calendar component. The categories are useful // in searching for the calendar component of a particular type and category. // https://tools.ietf.org/html/rfc5545#section-3.8.1.2 // https://tools.ietf.org/html/rfc7986#section-5.6 Categories []value.ListValue // Resources lists the equipment or resources anticipated for an activity specified // by the calendar component. // https://tools.ietf.org/html/rfc5545#section-3.8.1.10 Resources []value.ListValue // Sequence defines the revision sequence number of the calendar component within a // sequence of revisions. // https://tools.ietf.org/html/rfc5545#section-3.8.7.4 Sequence value.IntegerValue // Priority defines the relative priority for the calendar component // in the range 0 to 9; 0 is undefined; 1 is highest; 9 is lowest. // https://tools.ietf.org/html/rfc5545#section-3.8.1.9 Priority value.IntegerValue // Status defines the overall status or confirmation for the calendar component. // Examples: "TENTATIVE", "CONFIRMED". // https://tools.ietf.org/html/rfc5545#section-3.8.1.11 Status value.TextValue // Location defines the intended venue for the activity defined by the calendar component. // https://tools.ietf.org/html/rfc5545#section-3.8.1.7 Location value.TextValue // Geo specifies information related to the global position for the activity specified // by the calendar component. // https://tools.ietf.org/html/rfc5545#section-3.8.1.6 Geo value.GeoValue // Transparency defines whether or not an event is transparent to busy time searches. // https://tools.ietf.org/html/rfc5545#section-3.8.2.7 Transparency value.TextValue // Color specifies a color used for displaying the event data. The value is CSS3 color name. // Also allowed in the enclosing calendar data. // https://tools.ietf.org/html/rfc7986#section-5.9 Color value.TextValue // CSS3 color name // Attach provides the capability to associate a document object with the calendar component. // https://tools.ietf.org/html/rfc5545#section-3.8.1.1 Attach []value.Attachable // Image specifies an image or images associated with the calendar or the calendar component. // https://tools.ietf.org/html/rfc7986#section-5.10 Image []value.Attachable // Alarm attaches as many alarms to the event as are required. Alarm []VAlarm }
VEvent captures a calendar event. https://tools.ietf.org/html/rfc5545#section-3.6.1
Example (Meeting) ¶
package main import ( "fmt" "github.com/rickb777/ical2" "github.com/rickb777/ical2/parameter" "github.com/rickb777/ical2/parameter/cutype" "github.com/rickb777/ical2/parameter/partstat" "github.com/rickb777/ical2/parameter/role" "github.com/rickb777/ical2/value" "time" ) func main() { dt := time.Date(2014, time.Month(1), 1, 8, 0, 0, 0, time.UTC) ds := dt.Add(48 * time.Hour) de := ds.Add(72 * time.Hour) shared := parameter.Parameters{ cutype.Individual(), role.ReqParticipant(), partstat.NeedsAction(), parameter.Rsvp(true), parameter.Single("X-NUM-GUESTS", "0"), } cath1 := value.CalAddress("cath.dragon@example.com"). With(shared...). With(parameter.CommonName("Cath Dragon")) ann1 := value.CalAddress("anne.bollin@example.com"). With(shared...). With(parameter.CommonName("Anne Bollin")) jane := value.CalAddress("jane.seemoor@example.com"). With(shared...). With(parameter.CommonName("Jane Seemoor")) ann2 := value.CalAddress("anne@cleves.com"). With(shared...). With(parameter.CommonName("Anne Cleaver")) cath2 := value.CalAddress("cath@thehowards.com"). With(shared...). With(parameter.CommonName("Cath Howard")) cath3 := value.CalAddress("catherine.parr@respectable.com"). With(shared...). With(parameter.CommonName("Cath Parr")) event := &ical2.VEvent{ UID: value.Text("0ibinszut0oiksq0sa0ac98d46@google.com"), DTStamp: value.TStamp(dt), Created: value.TStamp(dt.Add(-2 * time.Hour)), LastModified: value.TStamp(dt.Add(-1 * time.Hour)), Sequence: value.Integer(0), Status: value.Confirmed(), Start: value.TStamp(ds), End: value.TStamp(de), Organizer: value.CalAddress("ht@throne.com").With(parameter.CommonName("H.Tudwr")), Attendee: []value.URIValue{cath1, ann1, jane, ann2, cath2, cath3}, Summary: value.Text("Meet the family"), Description: value.Text("This is a great chance to meet each other!"), Location: value.Text("South Bank, London SE1 9PX"), Geo: value.Geo(51.506616, -0.11538874), Transparency: value.Opaque(), Comment: []value.TextValue{value.Text("History in the making")}, } c := ical2.NewVCalendar("-//My App//Event Calendar//EN").With(event) c.Method = value.Request() fmt.Println(c.String()) }
Output: BEGIN:VCALENDAR PRODID:-//My App//Event Calendar//EN VERSION:2.0 CALSCALE:GREGORIAN METHOD:REQUEST BEGIN:VEVENT DTSTART:20140103T080000Z DTEND:20140106T080000Z DTSTAMP:20140101T080000Z UID:0ibinszut0oiksq0sa0ac98d46@google.com ORGANIZER;CN=H.Tudwr:mailto:ht@throne.com ATTENDEE;CUTYPE=INDIVIDUAL;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP= TRUE;X-NUM-GUESTS=0;CN=Cath Dragon:mailto:cath.dragon@example.com ATTENDEE;CUTYPE=INDIVIDUAL;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP= TRUE;X-NUM-GUESTS=0;CN=Anne Bollin:mailto:anne.bollin@example.com ATTENDEE;CUTYPE=INDIVIDUAL;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP= TRUE;X-NUM-GUESTS=0;CN=Jane Seemoor:mailto:jane.seemoor@example.com ATTENDEE;CUTYPE=INDIVIDUAL;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP= TRUE;X-NUM-GUESTS=0;CN=Anne Cleaver:mailto:anne@cleves.com ATTENDEE;CUTYPE=INDIVIDUAL;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP= TRUE;X-NUM-GUESTS=0;CN=Cath Howard:mailto:cath@thehowards.com ATTENDEE;CUTYPE=INDIVIDUAL;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP= TRUE;X-NUM-GUESTS=0;CN=Cath Parr:mailto:catherine.parr@respectable.com SUMMARY:Meet the family DESCRIPTION:This is a great chance to meet each other! LOCATION:South Bank\, London SE1 9PX GEO;VALUE=FLOAT:51.506616;-0.11538874 COMMENT:History in the making CREATED:20140101T060000Z LAST-MODIFIED:20140101T070000Z SEQUENCE;VALUE=INTEGER:0 STATUS:CONFIRMED TRANSP:OPAQUE END:VEVENT END:VCALENDAR
Example (Recurrence) ¶
package main import ( "fmt" "github.com/rickb777/ical2" "github.com/rickb777/ical2/parameter" "github.com/rickb777/ical2/parameter/role" "github.com/rickb777/ical2/value" "time" ) func main() { dt := time.Date(2014, time.Month(1), 1, 7, 0, 0, 0, time.UTC) ds := dt.Add(time.Hour) de := ds.Add(5 * time.Hour) // Recurrence rule are sophisticated: see recur_test.go for many examples. rv := value.Recurrence(value.WEEKLY) rv.ByDay = []value.WeekDayNum{value.MO, value.WE, value.FR} event := &ical2.VEvent{ UID: value.Text("123"), URL: value.URI("http://example.com/a/b/123"), DTStamp: value.TStamp(dt), Start: value.DateTime(ds), End: value.DateTime(de), Organizer: value.CalAddress("ht@throne.com").With(parameter.CommonName("H.Tudwr")), Attendee: []value.URIValue{value.CalAddress("ann.blin@example.com"). With(role.ReqParticipant(), parameter.CommonName("Ann Blin"))}, Summary: value.Text("Event summary"), Description: value.Text("This describes the event."), Transparency: value.Opaque(), RecurrenceRule: rv, // can have RecurrenceDate too, in which case the event sets are unioned. // Use ExceptionDate to exclude specific dates from the event set. } c := ical2.NewVCalendar("-//My App//Event Calendar//EN").With(event) // usually you'd Encode to some io.Writer //c.Encode(w) // but for this example, we'll just stringify fmt.Println(c.String()) }
Output: BEGIN:VCALENDAR PRODID:-//My App//Event Calendar//EN VERSION:2.0 CALSCALE:GREGORIAN BEGIN:VEVENT DTSTART;VALUE=DATE-TIME:20140101T080000Z DTEND;VALUE=DATE-TIME:20140101T130000Z DTSTAMP:20140101T070000Z UID:123 URL;VALUE=URI:http://example.com/a/b/123 ORGANIZER;CN=H.Tudwr:mailto:ht@throne.com ATTENDEE;ROLE=REQ-PARTICIPANT;CN=Ann Blin:mailto:ann.blin@example.com SUMMARY:Event summary DESCRIPTION:This describes the event. RRULE;VALUE=RECUR:FREQ=WEEKLY;BYDAY=MO,WE,FR TRANSP:OPAQUE END:VEVENT END:VCALENDAR
Example (Timezone) ¶
package main import ( "fmt" "github.com/rickb777/ical2" "github.com/rickb777/ical2/parameter" "github.com/rickb777/ical2/parameter/display" "github.com/rickb777/ical2/parameter/feature" "github.com/rickb777/ical2/parameter/role" "github.com/rickb777/ical2/value" "time" ) func main() { const tz = "Europe/London" zone, _ := time.LoadLocation(tz) dt := time.Date(2014, time.Month(1), 1, 7, 0, 0, 0, zone) ds := dt.Add(time.Hour) de := ds.Add(5 * time.Hour) event := &ical2.VEvent{ UID: value.Text("123"), DTStamp: value.TStamp(dt), Start: value.DateTime(ds).With(parameter.TZid(tz)), End: value.DateTime(de).With(parameter.TZid(tz)), Organizer: value.CalAddress("ht@throne.com").With(parameter.CommonName("H.Tudwr")), Attendee: []value.URIValue{value.CalAddress("ann.blin@example.com"). With(role.ReqParticipant(), parameter.CommonName("Ann Blin"))}, Conference: []value.URIValue{value.URI("https://chat.example.com/audio?id=123456"). With(feature.Feature(feature.AUDIO, feature.VIDEO)).With(parameter.Label("Attendee dial-in"))}, Contact: value.Texts("T.Moore, Esq."), Summary: value.Text("Event summary"), Description: value.Text("This describes the event."), RelatedTo: value.Text("19960401-080045-4000F192713-0052@example.com"), Categories: value.Lists("MEETING"), Resources: value.Lists("CATERING", "CHAIRS"), Location: value.Text("South Bank, London SE1 9PX"), Transparency: value.Transparent(), Attach: []value.Attachable{value.Binary([]byte("ABC")). With(parameter.FmtType("text/plain"))}, Image: []value.Attachable{value.URI("http://example.com/images/party.png"). With(display.Badge(), parameter.FmtType("image/png"))}, } c := ical2.NewVCalendar("-//My App//Event Calendar//EN").With(event) // usually you'd Encode to some io.Writer //c.Encode(w) // but for this example, we'll just stringify fmt.Println(c.String()) }
Output: BEGIN:VCALENDAR PRODID:-//My App//Event Calendar//EN VERSION:2.0 CALSCALE:GREGORIAN BEGIN:VEVENT DTSTART;VALUE=DATE-TIME;TZID=Europe/London:20140101T080000 DTEND;VALUE=DATE-TIME;TZID=Europe/London:20140101T130000 DTSTAMP:20140101T070000Z UID:123 ORGANIZER;CN=H.Tudwr:mailto:ht@throne.com ATTENDEE;ROLE=REQ-PARTICIPANT;CN=Ann Blin:mailto:ann.blin@example.com CONFERENCE;VALUE=URI;FEATURE=AUDIO,VIDEO;LABEL=Attendee dial-in:https://cha t.example.com/audio?id=123456 CONTACT:T.Moore\, Esq. SUMMARY:Event summary DESCRIPTION:This describes the event. LOCATION:South Bank\, London SE1 9PX RELATED-TO:19960401-080045-4000F192713-0052@example.com CATEGORIES:MEETING RESOURCES:CATERING,CHAIRS TRANSP:TRANSPARENT ATTACH;VALUE=BINARY;ENCODING=BASE64;FMTTYPE=text/plain:QUJD IMAGE;VALUE=URI;DISPLAY=BADGE;FMTTYPE=image/png:http://example.com/images/p arty.png END:VEVENT END:VCALENDAR
type VFreeBusy ¶
type VFreeBusy struct { UID value.TextValue DTStamp value.DateTimeValue Start value.DateTimeValue End value.DateTimeValue Organizer value.URIValue URL value.URIValue Contact value.TextValue Attendee []value.URIValue Comment []value.TextValue FreeBusy []value.PeriodValue }
VFreeBusy captures a calendar event
Example (Publish) ¶
package main import ( "fmt" "github.com/rickb777/date/v2/timespan" "github.com/rickb777/ical2" "github.com/rickb777/ical2/parameter/freebusy" "github.com/rickb777/ical2/value" "time" ) func main() { // This is an example of a "VFREEBUSY" calendar component used to publish busy time information. dt := time.Date(1997, time.Month(9), 1, 12, 0, 0, 0, time.UTC) ds := time.Date(1998, time.Month(3), 13, 14, 17, 11, 0, time.UTC) de := time.Date(1998, time.Month(4), 10, 14, 17, 11, 0, time.UTC) t1s := time.Date(1998, time.Month(3), 14, 23, 30, 0, 0, time.UTC) t2s := time.Date(1998, time.Month(3), 16, 15, 30, 0, 0, time.UTC) t3s := time.Date(1998, time.Month(3), 18, 3, 0, 0, 0, time.UTC) event := &ical2.VFreeBusy{ UID: value.Text("19970901T115957Z-76A912@example.com"), DTStamp: value.TStamp(dt), Start: value.DateTime(ds), End: value.DateTime(de), Organizer: value.CalAddress("jsmith@example.com"), URL: value.URI("http://www.example.com/calendar/busytime/jsmith.ifb"), FreeBusy: []value.PeriodValue{ value.Period(timespan.TimeSpanOf(t1s, time.Hour)).With(freebusy.Busy()), value.Period(timespan.TimeSpanOf(t2s, time.Hour)).With(freebusy.BusyTentative()), value.Period(timespan.TimeSpanOf(t3s, time.Hour)).With(freebusy.BusyUnavailable()), }, Comment: []value.TextValue{value.Text("Busy time")}, } c := ical2.NewVCalendar("-//My App//Event Calendar//EN").With(event) c.Method = value.Publish() // usually you'd Encode to some io.Writer //c.Encode(w) // but for this example, we'll just stringify fmt.Println(c.String()) }
Output: BEGIN:VCALENDAR PRODID:-//My App//Event Calendar//EN VERSION:2.0 CALSCALE:GREGORIAN METHOD:PUBLISH BEGIN:VFREEBUSY DTSTART;VALUE=DATE-TIME:19980313T141711Z DTEND;VALUE=DATE-TIME:19980410T141711Z DTSTAMP:19970901T120000Z UID:19970901T115957Z-76A912@example.com ORGANIZER:mailto:jsmith@example.com URL;VALUE=URI:http://www.example.com/calendar/busytime/jsmith.ifb COMMENT:Busy time FREEBUSY;VALUE=PERIOD;FBTYPE=BUSY:19980314T233000Z/PT1H FREEBUSY;VALUE=PERIOD;FBTYPE=BUSY-TENTATIVE:19980316T153000Z/PT1H FREEBUSY;VALUE=PERIOD;FBTYPE=BUSY-UNAVAILABLE:19980318T030000Z/PT1H END:VFREEBUSY END:VCALENDAR
Example (Request) ¶
package main import ( "fmt" "github.com/rickb777/ical2" "github.com/rickb777/ical2/value" "time" ) func main() { // This is an example of a "VFREEBUSY" calendar component used to request free or busy time information dt := time.Date(1997, time.Month(9), 1, 8, 30, 0, 0, time.UTC) ds := time.Date(1997, time.Month(10), 15, 5, 0, 0, 0, time.UTC) de := time.Date(1997, time.Month(10), 16, 5, 0, 0, 0, time.UTC) event := &ical2.VFreeBusy{ UID: value.Text("19970901T082949Z-FA43EF@example.com"), DTStamp: value.TStamp(dt), Start: value.DateTime(ds), End: value.DateTime(de), Organizer: value.CalAddress("jane_doe@example.com"), Attendee: []value.URIValue{value.CalAddress("john_public@example.com")}, } c := ical2.NewVCalendar("-//My App//Event Calendar//EN").With(event) c.Method = value.Request() // usually you'd Encode to some io.Writer //c.Encode(w) // but for this example, we'll just stringify fmt.Println(c.String()) }
Output: BEGIN:VCALENDAR PRODID:-//My App//Event Calendar//EN VERSION:2.0 CALSCALE:GREGORIAN METHOD:REQUEST BEGIN:VFREEBUSY DTSTART;VALUE=DATE-TIME:19971015T050000Z DTEND;VALUE=DATE-TIME:19971016T050000Z DTSTAMP:19970901T083000Z UID:19970901T082949Z-FA43EF@example.com ORGANIZER:mailto:jane_doe@example.com ATTENDEE:mailto:john_public@example.com END:VFREEBUSY END:VCALENDAR
Directories
¶
Path | Synopsis |
---|---|
Package ics provides low-level I/O support for the ical2 api.
|
Package ics provides low-level I/O support for the ical2 api. |
Package parameter handles iCalendar parameters.
|
Package parameter handles iCalendar parameters. |
cutype
Package cutype enumerates calendar user types.
|
Package cutype enumerates calendar user types. |
display
Package display enumerates values for the display parameter.
|
Package display enumerates values for the display parameter. |
feature
Package feature enumerates values for the feature parameter.
|
Package feature enumerates values for the feature parameter. |
freebusy
Package freebusy enumerates values for the free-busy parameter.
|
Package freebusy enumerates values for the free-busy parameter. |
partstat
Package partstat enumerates values for the participation status parameter.
|
Package partstat enumerates values for the participation status parameter. |
role
Package role enumerates values for the participation role parameter.
|
Package role enumerates values for the participation role parameter. |
value
Package value enumerates values of the type options for parameters (the VALUE parameter).
|
Package value enumerates values of the type options for parameters (the VALUE parameter). |