Skip to content

Commit

Permalink
a fix when there are no start_at or end_at dates
Browse files Browse the repository at this point in the history
  • Loading branch information
maccman committed Jan 29, 2012
1 parent 4d30f13 commit 8c76b3a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
4 changes: 2 additions & 2 deletions app/assets/javascripts/app/models/calendar_event.js.coffee
Expand Up @@ -7,8 +7,8 @@ class App.CalendarEvent extends Spine.Model

load: ->
super
@start_at = new Date(@start_at)
@end_at = new Date(@end_at)
@start_at = new Date(@start_at) if @start_at
@end_at = new Date(@end_at) if @end_at

@bind 'ajaxError', (_, e) ->
if e.status is 401
Expand Down
Expand Up @@ -6,7 +6,7 @@
<% for event in @events: %>
<div class="item">
<a href="<%= event.link %>">
<%= event.name %> <time><%= event.start_at.format('h:i a') %></time>
<%= event.name %> <time><%= event.start_at?.format('h:i a') %></time>
</a>
</div>
<% end %>
Expand Down
7 changes: 5 additions & 2 deletions lib/google.rb
Expand Up @@ -23,8 +23,11 @@ class Event
def initialize(result)
@link = result['htmlLink']
@name = result['summary']
@start_at = Time.parse(result['start']['date'])
@end_at = Time.parse(result['end']['date'])
@start_at = result['start']['date']
@end_at = result['end']['date']

@start_at = Time.parse(@start_at) if @start_at
@end_at = Time.parse(@end_at) if @end_at
end

def serializable_hash(options = nil)
Expand Down

0 comments on commit 8c76b3a

Please sign in to comment.