Introduction | calendar-links-go | Spatie       

 SPATIE  

calendar-links-go
=================

spatie.be/open-source

  [Docs](https://spatie.be/docs)  [Calendar-links-go](https://spatie.be/docs/calendar-links-go/v1)  Introduction

 Version   v1      

 Other versions for crawler [v1](https://spatie.be/docs/calendar-links-go/v1) 

  Introduction    
- [ Introduction ](https://spatie.be/docs/calendar-links-go/v1/introduction)
- [ Installation and setup ](https://spatie.be/docs/calendar-links-go/v1/installation-and-setup)
- [ Usage ](https://spatie.be/docs/calendar-links-go/v1/usage)
- [ Testing ](https://spatie.be/docs/calendar-links-go/v1/testing)
- [ Releasing ](https://spatie.be/docs/calendar-links-go/v1/releasing)
- [ Changelog ](https://spatie.be/docs/calendar-links-go/v1/changelog)
- [ Support us ](https://spatie.be/docs/calendar-links-go/v1/support-us)

  Calendar-links-go 
===================

 Generate add-to-calendar links for Google, Yahoo, Outlook and iCal 

### Useful links

- [Repository](https://github.com/spatie/calendar-links-go)
- [Discussions](https://github.com/spatie/calendar-links-go/discussions)

Introduction
------------

###  On this page 

1. [ Package principles ](#content-package-principles)

Using this package, you can generate links to add events to calendar systems. Here's a quick example:

```
zone, err := time.LoadLocation("Europe/Brussels")
if err != nil {
	return err
}
link, err := calendarlinks.New("Birthday party",
	time.Date(2027, 3, 15, 10, 0, 0, 0, zone),
	time.Date(2027, 3, 15, 17, 0, 0, 0, zone))
if err != nil {
	return err
}
fmt.Println(link.Google())
```

This will output:

```
https://calendar.google.com/calendar/render?action=TEMPLATE&dates=20270315T100000/20270315T170000&ctz=Europe/Brussels&text=Birthday+party
```

These snippets run inside a function returning `error`. Import `fmt`, `time`, and `calendarlinks "github.com/spatie/calendar-links-go"`.

Give both dates an explicit timezone, as above. The `ctz` parameter is taken from the start date.

Name a place (`Europe/Brussels`, or an alias of one such as `Japan` or `US/Pacific`) rather than an offset. Neither an offset nor an abbreviation gives a calendar service a place to resolve. The same goes for the IANA entries that stand for no place, including POSIX rule sets such as `EST` and `MST7MDT`, other spellings of UTC, and the whole `Etc/` family. Those timed events are written in UTC instead, so they land at the right instant everywhere, but the calendar has no zone to follow when daylight saving rules change. Pass `time.UTC`, not `Etc/UTC`, when you want a UTC endpoint alongside a named zone.

Dates use Go's `time.Time`. Use `time.LoadLocation` to load named zones and `time.Date` or `time.ParseInLocation` to construct local dates. `time.Parse(time.RFC3339, ...)` preserves the offset, but an offset alone does not identify a region. For a repeated local time, parse an explicit RFC 3339 offset and call `.In(zone)` to choose the intended instant. Go's `time.Date` does not guarantee which occurrence it picks.

Do not assign a region's name to `time.FixedZone`. It is a fixed offset, not that region's timezone rules. `time.Local` is also not a portable calendar timezone. Use an explicitly loaded IANA location instead.

If you follow that link and are authenticated with Google, you'll see a screen to add the event to your calendar.

The package can also generate ICS files that you can open in several email and calendar programs, including Microsoft Outlook, Google Calendar, and Apple Calendar.

Start with [installation and setup](installation-and-setup), then read [usage](usage).

Package principles
--------------------------------------------------------------------------------------------------------------

1. It should produce a small output to keep page size small.
2. It should be fast, with no external heavy dependencies.
3. All `Link` features should be supported by at least two generators. Different services have different features.

 A good
match?
-------------

### What we do best

- All things Laravel
- Custom frontend components
- Building APIs
- AI-powered features
- Simplifying things
- Clean solutions
- Integrating services

### Not our cup of tea

- WordPress themes
- Cutting corners
- Free mockups to win a job
- "Just execute the briefing"

 In short: we'd like to be a **substantial part** of your project.

 [ Get in touch via email ](mailto:info@spatie.be?subject=A%20good%20match%21&body=Tell%20us%20as%20much%20as%20you%20can%20about%0A-%20your%20online%20project%0A-%20your%20planning%0A-%20your%20budget%0A-%20%E2%80%A6%0A%0AAnything%20that%20helps%20us%20to%20start%20straightforward%21)
