Git Product home page Git Product logo

google-calendar-url's Introduction

google-calendar-url

Generate shareable URLs for adding Google Calendar events.

Features

Written in TypeScript and includes type definitions.

Try it in a CodeSandbox.

Installation

yarn add google-calendar-url
# or
npm install google-calendar-url --save

Usage

import { googleCalendarEventUrl } from 'google-calendar-url';

const url = googleCalendarEventUrl({
  start: '20201212T100000Z',
  end: '20201212T110000Z',
  title: 'Event title',
  details: 'Event details',
  location: 'San Francisco',
});

console.log(url);

// https://calendar.google.com/calendar/event?action=TEMPLATE&dates=20201212T100000Z%2F20201212T110000Z&text=Event+title&details=Event+details&location=San+Francisco

Try the URL

API

The googleCalendarEventUrl function takes a single GoogleCalendarEventArgs argument.

interface GoogleCalendarEventArgs {
  /**
   * Start of event, acceptable formats are:
   *
   * 20200316T010000Z - UTC
   *
   * 20200316T010000 - Time local to the user
   *
   * 20200316 - All day event
   */
  start?: string;

  /**
   * End of event, acceptable formats are:
   *
   * 20200316T010000Z - UTC
   *
   * 20200316T010000 - Time local to the user
   *
   * 20200316 - All day event
   */
  end?: string;

  /** Event title */
  title?: string;

  /** Event location */
  location?: string;

  /** Event details */
  details?: string;
}

References

Maintainers

google-calendar-url's People

Contributors

dependabot-preview[bot] avatar dependabot[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

reduardo7

google-calendar-url's Issues

Do more than string concatenation

Hey,

there is a great opportunity for this module to do a little more than just concatenate the strings together. The "difficult" part about the calendar links is getting the right format for the dates, since Google uses a rather unconventional format.
Without too much work you could enhance the functionality and let users pass real JS date objects for the dates, then format them:

const start = new Date(); // or whatever the user supplies
const formattedStart = start.toISOString().replace(/-/g, '').replace(/:/g, '').replace('.000', '');

This generates the correct format for a JS date object as input. Do the same for the end.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.