Add a way to get the ical representation to events.

master
Tom Hacohen 7 years ago
parent df538c368a
commit 441560dc72

6
src/ical.js.d.ts vendored

@ -11,6 +11,10 @@ declare module 'ical.js' {
getFirstProperty(name?: string): Property; getFirstProperty(name?: string): Property;
getAllProperties(name?: string): Array<Property>; getAllProperties(name?: string): Array<Property>;
updatePropertyWithValue(name: string, value: string | number | object): Property;
addSubcomponent(component: Component): Component;
} }
class Event { class Event {
@ -22,6 +26,8 @@ declare module 'ical.js' {
location: string; location: string;
attendees: Array<Property>; attendees: Array<Property>;
component: Component;
constructor(component?: Component | null, constructor(component?: Component | null,
options?: {strictExceptions: boolean, exepctions: Array<Component|Event>}); options?: {strictExceptions: boolean, exepctions: Array<Component|Event>});
} }

@ -3,6 +3,10 @@ import * as ICAL from 'ical.js';
export class EventType extends ICAL.Event { export class EventType extends ICAL.Event {
color: string; color: string;
static fromVCalendar(comp: ICAL.Component) {
return new EventType(comp.getFirstSubcomponent('vevent'));
}
get title() { get title() {
return this.summary; return this.summary;
} }
@ -15,8 +19,12 @@ export class EventType extends ICAL.Event {
return this.endDate.toJSDate(); return this.endDate.toJSDate();
} }
static fromVCalendar(comp: ICAL.Component) { toIcal() {
return new EventType(comp.getFirstSubcomponent('vevent')); let comp = new ICAL.Component(['vcalendar', [], []]);
comp.updatePropertyWithValue('prodid', '-//iCal.js EteSync Web');
comp.addSubcomponent(this.component);
return comp.toString();
} }
} }

Loading…
Cancel
Save