forked from shanebo/icalevent
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.js
More file actions
121 lines (103 loc) · 2.68 KB
/
example.js
File metadata and controls
121 lines (103 loc) · 2.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
var iCalEvent = require('icalevent');
var tzone = require('tzone');
var http = require('http');
var calendar = new iCalendar({
method: 'request',
name: 'Personal calendar',
description: 'Personal calendar of Johnny Boy'
}, [{
uid: 9873647,
offset: new Date().getTimezoneOffset(),
status: 'confirmed',
attendees: [
{
name: 'Johnny Boy',
email: 'johnny@numberfive.com'
},
{
name: 'Homer Simpson',
email: 'homer@powerplant.com'
}
],
start: '2014-07-01T02:00:00-05:00',
end: '2014-07-01T02:30:00-05:00',
timezone: 'US/Central',
summary: 'Priestly Duties',
description: 'Home flu visit.',
location: 'Casa',
organizer: {
name: 'Libre, Nacho',
email: 'luchador@monastery.org'
},
url: 'http://google.com/search?q=nacho+libre'
}, {
offset: new Date().getTimezoneOffset(),
status: 'confirmed',
attendees: [
{
name: 'Johnny Boy',
email: 'johnny@numberfive.com'
}
],
start: '2014-07-02T10:00:00-05:00',
end: '2014-07-02T11:30:00-05:00',
timezone: 'US/Central',
summary: 'Meet with Jane, bring cake',
location: 'Somewhere',
organizer: {
name: 'Doe, Jane',
email: 'jane@doe.com'
}
}]);
// or
var c = new iCalendar();
c.set('method', 'request');
c.set('name', 'Personal calendar');
c.set('description', 'Personal calendar of Johnny Boy');
var e = c.addEvent();
e.set('uid', 9873647);
e.set('offset', new Date().getTimezoneOffset());
e.set('status', 'confirmed');
e.set('attendees', [
{
name: 'Johnny Boy',
email: 'johnny@numberfive.com'
},
{
name: 'Homer Simpson',
email: 'homer@powerplant.com'
}
]);
e.set('start', '2014-07-01T02:00:00-05:00');
e.set('end', '2014-07-01T02:30:00-05:00');
e.set('timezone', 'US/Central');
e.set('summary', 'Priestly Duties.');
e.set('description', 'Home flu visit.');
e.set('location', 'Casa');
e.set('organizer', { name: 'Libre, Nacho', email: 'luchador@monastery.org' });
e.set('url', 'http://google.com/search?q=nacho+libre');
var e2 = c.addEvent();
e2.set('offset', new Date().getTimezoneOffset());
e2.set('status', 'confirmed');
e2.set('attendees', [
{
name: 'Johnny Boy',
email: 'johnny@numberfive.com'
}
]);
e2.set('start', '2014-07-02T10:00:00-05:00');
e2.set('end', '2014-07-02T11:30:00-05:00');
e2.set('timezone', 'US/Central');
e2.set('summary', 'Meet with Jane, bring cake');
e2.set('location', 'Somewhere');
e2.set('organizer', {name: 'Doe, Jane', email: 'jane@doe.com'});
console.log('\n');
console.log(c.toFile());
console.log('\n');
console.log(calendar.toFile());
http.createServer(function(request, response){
response.writeHead(200, {'Content-Type': 'text/calendar'});
var file = calendar.toFile();
response.end(file);
}).listen(9999, '127.0.0.1');
console.log('Server running at http://127.0.0.1:9999/');