Skip to content

Commit

Permalink
event config can include description
Browse files Browse the repository at this point in the history
  • Loading branch information
PeronGH committed Sep 7, 2022
1 parent b54de63 commit 3e3f21c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@ import {
Event,
EventConfig,
Calendar,
} from 'https://deno.land/x/[email protected].6/mod.ts';
} from 'https://deno.land/x/[email protected].7/mod.ts';

const cfg1: EventConfig = {
title: 'Write typescript',
title: 'Write Typescript',
beginDate: [2022, 9, 6, 9, 30],
endDate: [2022, 9, 6, 10],
description: 'Implement a module to generate .ics files',
};

const cfg2: EventConfig = {
Expand Down
10 changes: 8 additions & 2 deletions main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,13 @@ export class Event {
}
}

public toLines(): ContentLine[] {
toLines(): ContentLine[] {
const uid = crypto.randomUUID();
const { title } = this.config;
const { title, description } = this.config;

// Optional lines
const optLines: ContentLine[] = [];
if (description) optLines.push(['DESCRIPTION', description]);

return [
eventBegin,
Expand All @@ -48,6 +52,7 @@ export class Event {
['DTSTART', parseDate(this.config.beginDate)],
['DTEND', parseDate(this.config.endDate!)],
['SUMMARY', title],
...optLines,
eventEnd,
];
}
Expand All @@ -72,4 +77,5 @@ export interface EventConfig {
beginDate: DateData;
endDate?: DateData;
duration?: number;
description?: string;
}
4 changes: 3 additions & 1 deletion tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Deno.test({
title: 'test',
beginDate: [2022, 8, 1, 10, 10],
endDate: [2022, 8, 1, 11, 10],
description: 'Hello',
};
const evt = new Event(cfg);

Expand All @@ -33,9 +34,10 @@ Deno.test({
name: 'doc',
fn() {
const cfg1: EventConfig = {
title: 'Write typescript',
title: 'Write Typescript',
beginDate: [2022, 9, 6, 9, 30],
endDate: [2022, 9, 6, 10],
description: 'Implement a module to generate .ics files',
};

const cfg2: EventConfig = {
Expand Down

0 comments on commit 3e3f21c

Please sign in to comment.