Skip to content

Commit

Permalink
Updated links for outlook calendars (#543)
Browse files Browse the repository at this point in the history
updates the link format for outlook but also added additional links for mobile apps as these still support the older format and not the new one.
  • Loading branch information
M-J-Robbins committed May 31, 2023
1 parent de8789c commit 868ab57
Show file tree
Hide file tree
Showing 2 changed files with 89 additions and 1 deletion.
58 changes: 57 additions & 1 deletion src/index.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import dayjs from "dayjs";

import { google, yahoo, outlook, office365, ics } from "./index";
import { google, yahoo, outlook, outlookMobile, office365, office365Mobile, ics } from "./index";
import { TimeFormats } from "./utils";
import { CalendarEvent } from "./interfaces";

Expand Down Expand Up @@ -159,6 +159,34 @@ describe("Calendar Links", () => {
});
});

describe("OutlookMobile", () => {
test("generate a outlookMobile link", () => {
const event: CalendarEvent = {
title: "Birthday party",
start: "2019-12-29",
duration: [2, "hour"],
};
const link = outlookMobile(event);

expect(link).toBe(
`https://outlook.live.com/calendar/0/deeplink/compose?allday=false&enddt=2019-12-29T02%3A00%3A00&path=%2Fcalendar%2Faction%2Fcompose&rru=addevent&startdt=2019-12-29T00%3A00%3A00&subject=Birthday%20party`
);
});

test("generate an all day outlookMobile link", () => {
const event: CalendarEvent = {
title: "Birthday party",
start: "2019-12-29",
allDay: true,
};
const link = outlookMobile(event);

expect(link).toBe(
`https://outlook.live.com/calendar/0/deeplink/compose?allday=true&enddt=2019-12-30T00%3A00%3A00&path=%2Fcalendar%2Faction%2Fcompose&rru=addevent&startdt=2019-12-29T00%3A00%3A00&subject=Birthday%20party`
);
});
});

describe("Office365", () => {
test("generate a office365 link", () => {
const event: CalendarEvent = {
Expand Down Expand Up @@ -187,6 +215,34 @@ describe("Calendar Links", () => {
});
});

describe("Office365Mobile", () => {
test("generate a office365Mobile link", () => {
const event: CalendarEvent = {
title: "Birthday party",
start: "2019-12-29",
duration: [2, "hour"],
};
const link = office365Mobile(event);

expect(link).toBe(
`https://outlook.office.com/calendar/0/deeplink/compose?allday=false&enddt=2019-12-29T02%3A00%3A00&path=%2Fcalendar%2Faction%2Fcompose&rru=addevent&startdt=2019-12-29T00%3A00%3A00&subject=Birthday%20party`
);
});

test("generate an all day office365Mobile link", () => {
const event: CalendarEvent = {
title: "Birthday party",
start: "2019-12-29",
allDay: true,
};
const link = office365Mobile(event);

expect(link).toBe(
`https://outlook.office.com/calendar/0/deeplink/compose?allday=true&enddt=2019-12-30T00%3A00%3A00&path=%2Fcalendar%2Faction%2Fcompose&rru=addevent&startdt=2019-12-29T00%3A00%3A00&subject=Birthday%20party`
);
});
});

describe("ICS", () => {
test("should generate an all day ics link", () => {
const event: CalendarEvent = {
Expand Down
32 changes: 32 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,22 @@ export const google = (calendarEvent: CalendarEvent): string => {
};

export const outlook = (calendarEvent: CalendarEvent): string => {
const event = eventify(calendarEvent, false);
const { start, end } = formatTimes(event, "dateTimeLocal");
const details: Outlook = {
path: "/calendar/action/compose",
rru: "addevent",
startdt: start,
enddt: end,
subject: event.title,
body: event.description,
location: event.location,
allday: event.allDay || false,
};
return `https://outlook.live.com/calendar/0/action/compose?${stringify(details)}`;
};

export const outlookMobile = (calendarEvent: CalendarEvent): string => {
const event = eventify(calendarEvent, false);
const { start, end } = formatTimes(event, "dateTimeLocal");
const details: Outlook = {
Expand All @@ -82,6 +98,22 @@ export const outlook = (calendarEvent: CalendarEvent): string => {
};

export const office365 = (calendarEvent: CalendarEvent): string => {
const event = eventify(calendarEvent, false);
const { start, end } = formatTimes(event, "dateTimeLocal");
const details: Outlook = {
path: "/calendar/action/compose",
rru: "addevent",
startdt: start,
enddt: end,
subject: event.title,
body: event.description,
location: event.location,
allday: event.allDay || false,
};
return `https://outlook.office.com/calendar/0/action/compose?${stringify(details)}`;
};

export const office365Mobile = (calendarEvent: CalendarEvent): string => {
const event = eventify(calendarEvent, false);
const { start, end } = formatTimes(event, "dateTimeLocal");
const details: Outlook = {
Expand Down

0 comments on commit 868ab57

Please sign in to comment.