mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-09-07 21:55:20 +08:00
Fix new year problems with activities
Closes SCI-876.
This commit is contained in:
parent
aba12b9b2c
commit
8b01f912a0
3 changed files with 12 additions and 6 deletions
|
@ -1,4 +1,6 @@
|
|||
class ActivitiesController < ApplicationController
|
||||
include ActivityHelper
|
||||
|
||||
before_filter :load_vars
|
||||
|
||||
def index
|
||||
|
@ -14,8 +16,8 @@ class ActivitiesController < ApplicationController
|
|||
# Whether to hide date labels
|
||||
@hide_today = params.include? :from
|
||||
@day = @last_activity.present? ?
|
||||
@last_activity.created_at.strftime("%j").to_i :
|
||||
366
|
||||
days_since_1970(@last_activity.created_at) :
|
||||
days_since_1970(DateTime.current + 30.days)
|
||||
|
||||
more_url = url_for(activities_url(format: :json,
|
||||
from: @activities.last.id))
|
||||
|
|
|
@ -10,4 +10,8 @@ module ActivityHelper
|
|||
message = message.gsub(/#{activity_title}/, title )
|
||||
message.html_safe if message
|
||||
end
|
||||
|
||||
def days_since_1970(dt)
|
||||
dt.to_i / 86400
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<%
|
||||
current_day = DateTime.current.strftime('%j').to_i
|
||||
current_day = days_since_1970(DateTime.current)
|
||||
%>
|
||||
<% if !hide_today and activities.count > 0 and activities[0].created_at.strftime('%j').to_i == current_day %>
|
||||
<% if !hide_today and activities.count > 0 and days_since_1970(activities[0].created_at) == current_day %>
|
||||
<li class="text-center activity-date-item">
|
||||
<span class="label label-primary">
|
||||
<%=t "activities.index.today" %>
|
||||
|
@ -9,10 +9,10 @@
|
|||
</li>
|
||||
<% end %>
|
||||
<% activities.each do |activity| %>
|
||||
<% activity_day = activity.created_at.strftime('%j').to_i %>
|
||||
<% activity_day = days_since_1970(activity.created_at) %>
|
||||
|
||||
<% if activity_day < current_day and activity_day < day %>
|
||||
<% day = activity.created_at.strftime('%j').to_i %>
|
||||
<% day = days_since_1970(activity.created_at) %>
|
||||
<li class="text-center activity-date-item">
|
||||
<span class="label label-primary">
|
||||
<%= activity.created_at.strftime('%d.%m.%Y') %>
|
||||
|
|
Loading…
Add table
Reference in a new issue