From c39be899b629378c0a4e1dd4beab528ebcbffa6e Mon Sep 17 00:00:00 2001 From: Scott Gerring Date: Sat, 3 Nov 2012 13:18:40 +0800 Subject: Display 'last updated' using user's locale. Closes #10 --- javascripts/dashing.coffee | 6 ++++-- lib/dashing.rb | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/javascripts/dashing.coffee b/javascripts/dashing.coffee index 6662725..faf21a0 100644 --- a/javascripts/dashing.coffee +++ b/javascripts/dashing.coffee @@ -44,8 +44,10 @@ class Dashing.Widget extends Batman.View @accessor 'updatedAtMessage', -> if updatedAt = @get('updatedAt') - timestamp = updatedAt.toString().match(/\d*:\d*/)[0] - "Last updated at #{timestamp}" + timestamp = new Date(updatedAt * 1000) + hours = timestamp.getHours() + minutes = ("0" + timestamp.getMinutes()).slice(-2) + "Last updated at #{hours}:#{minutes}" @::on 'ready', -> Dashing.Widget.fire 'ready' diff --git a/lib/dashing.rb b/lib/dashing.rb index 7d066cc..37dc54d 100644 --- a/lib/dashing.rb +++ b/lib/dashing.rb @@ -81,7 +81,7 @@ end def send_event(id, body) body["id"] = id - body["updatedAt"] = Time.now + body["updatedAt"] = Time.now.to_i event = format_event(body.to_json) settings.history[id] = event settings.connections.each { |out| out << event } -- cgit v1.2.3