Skip to content

Commit

Permalink
fix: timezone settings
Browse files Browse the repository at this point in the history
  • Loading branch information
qiao committed Aug 21, 2011
1 parent 4caef5a commit db79053
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 15 deletions.
4 changes: 0 additions & 4 deletions app/helpers/comments_helper.rb
@@ -1,8 +1,4 @@
module CommentsHelper
def publish_time(comment)
comment.created_at.in_time_zone(8).strftime("%Y-%m-%d %X")
end

def gravatar_for(comment)
gravatar_image_tag(comment.author_email.downcase,
:alt => comment.author_name,
Expand Down
4 changes: 0 additions & 4 deletions app/models/commentable.rb
Expand Up @@ -13,10 +13,6 @@ class Commentable < ActiveRecord::Base
scope :published, where(:published => true)
scope :draft, where(:published => false)

def published_at
created_at.in_time_zone(8)
end

private
def update_content
self.content = markdown(self.raw_content)
Expand Down
2 changes: 1 addition & 1 deletion app/views/comments/_comment.html.erb
Expand Up @@ -12,7 +12,7 @@
</div>
<div class="comment_content">
<div class="comment_info">
<%= publish_time(comment) %>
<%= comment.created_at.strftime('%Y-%m-%d %X') %>
</div>
<%= simple_format(comment.content) %>
</div>
Expand Down
4 changes: 2 additions & 2 deletions app/views/pages/_page.html.erb
@@ -1,12 +1,12 @@
<div class="page_title">
<h2><%= link_to page.title, page_url(page) %></h2>
<%if logged_in? %>
<%= link_to "[edit]", edit_admin_page_url(page) %>
<%= link_to '[edit]', edit_admin_page_url(page) %>
<% end %>
</div>

<div class="page_info">
Posted on <%= page.published_at.strftime("%Y-%m-%d %X") %>
Posted on <%= page.created_at.strftime('%Y-%m-%d %X') %>
</div>

<div class="page_content">
Expand Down
6 changes: 3 additions & 3 deletions app/views/posts/_post.html.erb
@@ -1,14 +1,14 @@
<div class="post_title">
<h2><%= link_to post.title, post_url(post) %></h2>
<% if logged_in? %>
<%= link_to "[edit]", edit_admin_post_url(post),
:class => "post_edit_button" %>
<%= link_to '[edit]', edit_admin_post_url(post),
:class => 'post_edit_button' %>
<% end %>
</div>

<div class="post_info">
<div class="post_date">
Posted on <%= post.published_at.strftime("%Y-%m-%d %X") %>
Posted on <%= post.created_at.strftime('%Y-%m-%d %X') %>
</div>
<% unless post.tag_list.empty? %>
<div class="post_tags">
Expand Down
2 changes: 1 addition & 1 deletion config/application.rb
Expand Up @@ -24,7 +24,7 @@ class Application < Rails::Application

# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
# config.time_zone = 'Central Time (US & Canada)'
config.time_zone = 'Beijing'

# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
Expand Down

0 comments on commit db79053

Please sign in to comment.