Skip to content

Commit

Permalink
Add AOL Link support (#546)
Browse files Browse the repository at this point in the history
* refactor(src/index.ts): add aol links

* refactor(src/interfaces.ts): add aol links

* refactor(index.spec.ts): add aol link tests
  • Loading branch information
0Charliecat committed Jun 12, 2023
1 parent 868ab57 commit 065f080
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 1 deletion.
32 changes: 32 additions & 0 deletions src/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,38 @@ describe("Calendar Links", () => {
);
});
});

describe("Aol", () => {
test("generate a aol link", () => {
const event: CalendarEvent = {
title: "Birthday party",
start: "2019-12-29",
duration: [2, "hour"],
};
const link = yahoo(event);
const sTime: String = dayjs(event.start).utc().format(TimeFormats.dateTimeUTC);
const eTime: String = dayjs(event.start).add(2, "hour").utc().format(TimeFormats.dateTimeUTC);

expect(link).toBe(
`https://calendar.aol.com/?dur=false&et=${eTime}&st=${sTime}&title=Birthday%20party&v=60`
);
});

test("generate an all day aol link", () => {
const event: CalendarEvent = {
title: "Birthday party",
start: "2019-12-29",
allDay: true,
};
const link = yahoo(event);
const sTime: String = dayjs(event.start).utc().format(TimeFormats.allDay);
const eTime: String = dayjs(event.start).add(1, "day").utc().format(TimeFormats.allDay);

expect(link).toBe(
`https://calendar.aol.com/?dur=allday&et=${eTime}&st=${sTime}&title=Birthday%20party&v=60`
);
});
});

describe("ICS", () => {
test("should generate an all day ics link", () => {
Expand Down
16 changes: 16 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
CalendarEvent,
CalendarEventOrganizer,
NormalizedCalendarEvent,
Aol,
Google,
Outlook,
Yahoo,
Expand Down Expand Up @@ -144,6 +145,21 @@ export const yahoo = (calendarEvent: CalendarEvent): string => {
return `https://calendar.yahoo.com/?${stringify(details)}`;
};

export const aol = (calendarEvent: CalendarEvent): string => {
const event = eventify(calendarEvent);
const { start, end } = formatTimes(event, event.allDay ? "allDay" : "dateTimeUTC");
const details: Aol = {
v: 60,
title: event.title,
st: start,
et: end,
desc: event.description,
in_loc: event.location,
dur: event.allDay ? "allday" : false,
};
return `https://calendar.aol.com/?${stringify(details)}`;
};

export const ics = (calendarEvent: CalendarEvent): string => {
const event = eventify(calendarEvent);
const formattedDescription: string = (event.description || "")
Expand Down
11 changes: 10 additions & 1 deletion src/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,13 @@ interface Yahoo extends Record<string, string | boolean | number | undefined> {
in_loc?: string;
}

export { CalendarEvent, CalendarEventOrganizer, NormalizedCalendarEvent, Outlook, Yahoo, Google };
interface Aol extends Record<string, string | boolean | number | undefined> {
v: number;
title: string;
st: string;
et: string;
desc?: string;
in_loc?: string;
}

export { CalendarEvent, CalendarEventOrganizer, NormalizedCalendarEvent, Outlook, Yahoo, Google, Aol };

0 comments on commit 065f080

Please sign in to comment.