diff options
author | Rhenium <rhenium@rhe.jp> | 2014-01-24 04:48:25 +0900 |
---|---|---|
committer | Rhenium <rhenium@rhe.jp> | 2014-01-24 04:48:25 +0900 |
commit | 35d814853b5d794a409f905a970cd41235d6ff9e (patch) | |
tree | 815690d84349e5cb32bcadd69ccf91e0f37dff9f | |
parent | 3b8bc9f15cc64e62986da9a6ec6b106d3ccc41b4 (diff) | |
download | aclog-35d814853b5d794a409f905a970cd41235d6ff9e.tar.gz |
convert tweeted_at to localtime in JavaScript
-rw-r--r-- | app/assets/javascripts/tweets.js | 8 | ||||
-rw-r--r-- | app/helpers/application_helper.rb | 4 | ||||
-rw-r--r-- | app/views/tweets/_tweet.html.haml | 6 |
3 files changed, 11 insertions, 7 deletions
diff --git a/app/assets/javascripts/tweets.js b/app/assets/javascripts/tweets.js index b56c8f0..7cec8d1 100644 --- a/app/assets/javascripts/tweets.js +++ b/app/assets/javascripts/tweets.js @@ -1,6 +1,9 @@ //= require _html-autoload $(function() { - $(".pagination").hide(); + var format_tweet = function() { + $("time").text(new Date($("time").attr("datetime")).toLocaleString()); + }; + $.autopager({ content: $(".tweets"), link: $("link[rel=next]"), @@ -9,7 +12,10 @@ $(function() { }, onComplete: function() { $(".loading").hide(); + format_tweet(); } }); + + format_tweet(); }); diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 4c3e5a4..3d5eedd 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1,10 +1,6 @@ module ApplicationHelper include Twitter::Autolink - def format_time(dt) - dt.to_time.localtime("+09:00").strftime("%Y-%m-%d %H:%M:%S") - end - def title(*args) content_for :title do (args.compact).join(" - ") diff --git a/app/views/tweets/_tweet.html.haml b/app/views/tweets/_tweet.html.haml index 9df1cf6..90a74ad 100644 --- a/app/views/tweets/_tweet.html.haml +++ b/app/views/tweets/_tweet.html.haml @@ -14,7 +14,8 @@ ユーザーは非公開です .meta.clearfix %span.twitter_bird= image_tag("bird_gray_16.png", alt: "Twitter") - %span.created_at= format_time(tweet.tweeted_at) + %span.created_at + %time{datetime: tweet.tweeted_at.to_datetime.rfc3339} %span.source via - .stats %dl @@ -47,7 +48,8 @@ %span.twitter_bird = link_to image_tag("bird_gray_16.png", alt: "Twitter"), tweet.twitter_url, target: "_blank" %span.created_at - = link_to format_time(tweet.tweeted_at), tweet_path(tweet.id) + = link_to tweet_path(tweet.id) do + %time{datetime: tweet.tweeted_at.to_datetime.rfc3339} - if favorites_truncated?(tweet) %span.show-full= link_to "show full", tweet_path(tweet.id, full: true) - if logged_in? |