-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathevent.coffee
More file actions
33 lines (26 loc) · 886 Bytes
/
event.coffee
File metadata and controls
33 lines (26 loc) · 886 Bytes
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
moment = require 'moment'
rest = require 'restler'
ical = require 'ical'
require 'datejs'
event_feed = 'http://www.google.com/calendar/ical/nodekc.org_e8lg6hesldeld1utui23ebpg7k%40group.calendar.google.com/public/basic.ics'
formatDate = (start, end) ->
start = moment(start.setTimezone('CST'))
end = moment(end.setTimezone('CST'))
date = start.format('ddd, MMM D')
if end.diff(start, 'days') == 1 and start.hours() == 0
return date
date + start.format(' h:mma CST')
Event = (data) ->
this.title = data.summary
this.location = data.location
this.details = data.description
this.when = formatDate(data.start, data.end)
this.url = 'http://calendar.nodekc.org'
return
Event.load = (cb) ->
ical.fromURL event_feed, {}, (err, calendar) ->
calendar or= {}
events = for k,v of calendar
new Event v
cb events
module.exports = Event