 Template.edit_event.events
   'submit .create-event': (e) ->
     e.preventDefault()
-    event = parseEventFromForm($('.create-event'))
+    event = parse_event_from_form $('.create-event')
     Events.update(event.id, $set: event)
     Session.set('editing', null)
 

Template.new.helpers
  'empty_object': {}

parseEventFromForm = (form) ->
  event = form.serializeObject()
  event.categories = fix_categories(event.categories)

  dateStart = moment(event.date_start, DATE_FORMAT)
  timeStart = moment(event.time_start, TIME_FORMAT)

  delete event['date_start']
  delete event['time_start']

  event.from = dateStart
    .hour(timeStart.hour())
    .minute(timeStart.minute())
    .toDate()

  dateEnd = moment(event.date_end, DATE_FORMAT)
  timeEnd = moment(event.time_end, TIME_FORMAT)

  delete event['date_end']
  delete event['time_end']

  event.to = dateEnd
    .hour(timeEnd.hour())
    .minute(timeEnd.minute())
    .toDate()

  console.log event.from, event.to

  return event

Template.new.events
  'submit .create-event': (e) ->
    e.preventDefault()
    event = parseEventFromForm($('.create-event'))

    user = Meteor.user()
    event.creator = user._id

      o[@name] = @value or ""
  return o

moment.lang 'en',
  calendar:
    lastWeek: '[last] dddd [at] LT',
    lastDay: '[Yesterday,] LT',
    sameDay: '[Today,] LT',
    nextDay: '[Tomorrow,] LT',
    nextWeek: 'dddd, LT',
    sameElse: 'dddd, L[,] LT'

DATE_FORMAT = "YYYY-MM-DD"
TIME_FORMAT = "HH:mm"
