Use time.zone functions instead of server time functions
(Time.zone.today vs Date.today)
This commit is contained in:
parent
14bc2b99b9
commit
9de9a1fd71
7 changed files with 10 additions and 10 deletions
|
@ -163,8 +163,8 @@ class StatsController < ApplicationController
|
|||
def contact_percentage
|
||||
number_of_months = 13
|
||||
|
||||
from = Date.today.prev_month(number_of_months)
|
||||
to = Date.today.prev_month
|
||||
from = Time.zone.today.prev_month(number_of_months)
|
||||
to = Time.zone.today.prev_month
|
||||
|
||||
adapter = Helpscout::UserConversationsAdapter.new(from, to)
|
||||
if !adapter.can_fetch_reports?
|
||||
|
|
|
@ -18,7 +18,7 @@ module CommentaireHelper
|
|||
end
|
||||
|
||||
def commentaire_date(commentaire)
|
||||
is_current_year = (commentaire.created_at.year == Date.current.year)
|
||||
is_current_year = (commentaire.created_at.year == Time.zone.today.year)
|
||||
template = is_current_year ? :message_date : :message_date_with_year
|
||||
I18n.l(commentaire.created_at, format: template)
|
||||
end
|
||||
|
|
|
@ -35,7 +35,7 @@ class Helpscout::UserConversationsAdapter
|
|||
end
|
||||
|
||||
def fetch_productivity_report(year, month)
|
||||
if year == Date.today.year && month == Date.today.month
|
||||
if year == Time.zone.today.year && month == Time.zone.today.month
|
||||
raise ArgumentError, 'The report for the current month will change in the future, and cannot be cached.'
|
||||
end
|
||||
|
||||
|
|
|
@ -6,11 +6,11 @@ class Champs::DateChamp < Champ
|
|||
end
|
||||
|
||||
def to_s
|
||||
value.present? ? I18n.l(Date.parse(value)) : ""
|
||||
value.present? ? I18n.l(Time.zone.parse(value), format: '%d %B %Y') : ""
|
||||
end
|
||||
|
||||
def for_tag
|
||||
value.present? ? I18n.l(Date.parse(value)) : ""
|
||||
value.present? ? I18n.l(Time.zone.parse(value), format: '%d %B %Y') : ""
|
||||
end
|
||||
|
||||
private
|
||||
|
@ -18,7 +18,7 @@ class Champs::DateChamp < Champ
|
|||
def format_before_save
|
||||
self.value =
|
||||
begin
|
||||
Date.parse(value).iso8601
|
||||
Time.zone.parse(value).to_date.iso8601
|
||||
rescue
|
||||
nil
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue