Fix rubocop Rails/TimeZone warnings
This commit is contained in:
parent
304eb3b75c
commit
b5f06e06c1
48 changed files with 89 additions and 96 deletions
|
@ -307,11 +307,11 @@ module Api
|
|||
times = time.split(",")
|
||||
raise OSM::APIBadUserInput, "bad time range" if times.size != 2
|
||||
|
||||
from, to = times.collect { |t| Time.parse(t) }
|
||||
from, to = times.collect { |t| Time.parse(t).utc }
|
||||
changesets.where("closed_at >= ? and created_at <= ?", from, to)
|
||||
else
|
||||
# if there is no comma, assume its a lower limit on time
|
||||
changesets.where("closed_at >= ?", Time.parse(time))
|
||||
changesets.where("closed_at >= ?", Time.parse(time).utc)
|
||||
end
|
||||
# stupid Time seems to throw both of these for bad parsing, so
|
||||
# we have to catch both and ensure the correct code path is taken.
|
||||
|
@ -329,7 +329,7 @@ module Api
|
|||
changesets
|
||||
else
|
||||
changesets.where("closed_at >= ? and num_changes <= ?",
|
||||
Time.now.getutc, Changeset::MAX_ELEMENTS)
|
||||
Time.now.utc, Changeset::MAX_ELEMENTS)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -341,7 +341,7 @@ module Api
|
|||
changesets
|
||||
else
|
||||
changesets.where("closed_at < ? or num_changes > ?",
|
||||
Time.now.getutc, Changeset::MAX_ELEMENTS)
|
||||
Time.now.utc, Changeset::MAX_ELEMENTS)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -277,16 +277,16 @@ module Api
|
|||
# Add any date filter
|
||||
if params[:from]
|
||||
begin
|
||||
from = Time.parse(params[:from])
|
||||
from = Time.parse(params[:from]).utc
|
||||
rescue ArgumentError
|
||||
raise OSM::APIBadUserInput, "Date #{params[:from]} is in a wrong format"
|
||||
end
|
||||
|
||||
begin
|
||||
to = if params[:to]
|
||||
Time.parse(params[:to])
|
||||
Time.parse(params[:to]).utc
|
||||
else
|
||||
Time.now
|
||||
Time.now.utc
|
||||
end
|
||||
rescue ArgumentError
|
||||
raise OSM::APIBadUserInput, "Date #{params[:to]} is in a wrong format"
|
||||
|
@ -361,7 +361,7 @@ module Api
|
|||
elsif closed_since.positive?
|
||||
notes.where(:status => "open")
|
||||
.or(notes.where(:status => "closed")
|
||||
.where(notes.arel_table[:closed_at].gt(Time.now - closed_since.days)))
|
||||
.where(notes.arel_table[:closed_at].gt(Time.now.utc - closed_since.days)))
|
||||
else
|
||||
notes.where(:status => "open")
|
||||
end
|
||||
|
|
|
@ -108,7 +108,7 @@ module Api
|
|||
:visibility => visibility,
|
||||
:inserted => false,
|
||||
:user => current_user,
|
||||
:timestamp => Time.now.getutc,
|
||||
:timestamp => Time.now.utc,
|
||||
:file => file
|
||||
)
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ class FriendshipsController < ApplicationController
|
|||
friendship.befriendee = @new_friend
|
||||
if current_user.is_friends_with?(@new_friend)
|
||||
flash[:warning] = t "friendships.make_friend.already_a_friend", :name => @new_friend.display_name
|
||||
elsif current_user.friendships.where("created_at >= ?", Time.now.getutc - 1.hour).count >= current_user.max_friends_per_hour
|
||||
elsif current_user.friendships.where("created_at >= ?", Time.now.utc - 1.hour).count >= current_user.max_friends_per_hour
|
||||
flash.now[:error] = t "friendships.make_friend.limit_exceeded"
|
||||
elsif friendship.save
|
||||
flash[:notice] = t "friendships.make_friend.success", :name => @new_friend.display_name
|
||||
|
|
|
@ -24,9 +24,9 @@ class MessagesController < ApplicationController
|
|||
@message = Message.new(message_params)
|
||||
@message.recipient = @user
|
||||
@message.sender = current_user
|
||||
@message.sent_on = Time.now.getutc
|
||||
@message.sent_on = Time.now.utc
|
||||
|
||||
if current_user.sent_messages.where("sent_on >= ?", Time.now.getutc - 1.hour).count >= current_user.max_messages_per_hour
|
||||
if current_user.sent_messages.where("sent_on >= ?", Time.now.utc - 1.hour).count >= current_user.max_messages_per_hour
|
||||
flash.now[:error] = t ".limit_exceeded"
|
||||
render :action => "new"
|
||||
elsif @message.save
|
||||
|
|
|
@ -119,7 +119,7 @@ class TracesController < ApplicationController
|
|||
:description => params[:trace][:description],
|
||||
:visibility => params[:trace][:visibility],
|
||||
:inserted => false, :user => current_user,
|
||||
:timestamp => Time.now.getutc)
|
||||
:timestamp => Time.now.utc)
|
||||
@trace.valid?
|
||||
@trace.errors.add(:gpx_file, "can't be blank")
|
||||
|
||||
|
@ -266,7 +266,7 @@ class TracesController < ApplicationController
|
|||
:visibility => visibility,
|
||||
:inserted => false,
|
||||
:user => current_user,
|
||||
:timestamp => Time.now.getutc,
|
||||
:timestamp => Time.now.utc,
|
||||
:file => file
|
||||
)
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ class UserBlocksController < ApplicationController
|
|||
end
|
||||
|
||||
def edit
|
||||
params[:user_block_period] = ((@user_block.ends_at - Time.now.getutc) / 1.hour).ceil.to_s
|
||||
params[:user_block_period] = ((@user_block.ends_at - Time.now.utc) / 1.hour).ceil.to_s
|
||||
end
|
||||
|
||||
def create
|
||||
|
@ -41,7 +41,7 @@ class UserBlocksController < ApplicationController
|
|||
:user => @user,
|
||||
:creator => current_user,
|
||||
:reason => params[:user_block][:reason],
|
||||
:ends_at => Time.now.getutc + @block_period.hours,
|
||||
:ends_at => Time.now.utc + @block_period.hours,
|
||||
:needs_view => params[:user_block][:needs_view]
|
||||
)
|
||||
|
||||
|
@ -62,7 +62,7 @@ class UserBlocksController < ApplicationController
|
|||
flash[:error] = t(".only_creator_can_edit")
|
||||
redirect_to :action => "edit"
|
||||
elsif @user_block.update(
|
||||
:ends_at => Time.now.getutc + @block_period.hours,
|
||||
:ends_at => Time.now.utc + @block_period.hours,
|
||||
:reason => params[:user_block][:reason],
|
||||
:needs_view => params[:user_block][:needs_view]
|
||||
)
|
||||
|
|
|
@ -55,8 +55,8 @@ class UsersController < ApplicationController
|
|||
elsif current_user
|
||||
unless current_user.terms_agreed?
|
||||
current_user.consider_pd = params[:user][:consider_pd]
|
||||
current_user.tou_agreed = Time.now.getutc
|
||||
current_user.terms_agreed = Time.now.getutc
|
||||
current_user.tou_agreed = Time.now.utc
|
||||
current_user.terms_agreed = Time.now.utc
|
||||
current_user.terms_seen = true
|
||||
|
||||
flash[:notice] = t "users.new.terms accepted" if current_user.save
|
||||
|
@ -73,8 +73,8 @@ class UsersController < ApplicationController
|
|||
current_user.description = "" if current_user.description.nil?
|
||||
current_user.creation_ip = request.remote_ip
|
||||
current_user.languages = http_accept_language.user_preferred_languages
|
||||
current_user.terms_agreed = Time.now.getutc
|
||||
current_user.tou_agreed = Time.now.getutc
|
||||
current_user.terms_agreed = Time.now.utc
|
||||
current_user.tou_agreed = Time.now.utc
|
||||
current_user.terms_seen = true
|
||||
|
||||
if current_user.auth_uid.blank?
|
||||
|
|
|
@ -10,7 +10,7 @@ module ChangesetsHelper
|
|||
end
|
||||
|
||||
def changeset_details(changeset)
|
||||
if changeset.closed_at > Time.now
|
||||
if changeset.closed_at > Time.now.utc
|
||||
action = :created
|
||||
time = time_ago_in_words(changeset.created_at, :scope => :"datetime.distance_in_words_ago")
|
||||
title = l(changeset.created_at)
|
||||
|
|
|
@ -8,7 +8,7 @@ module UserBlocksHelper
|
|||
if block.active?
|
||||
# if the block hasn't expired yet show the date, if the user just needs to login show that
|
||||
if block.needs_view?
|
||||
if block.ends_at > Time.now.getutc
|
||||
if block.ends_at > Time.now.utc
|
||||
t("user_blocks.helper.time_future_and_until_login_html", :time => friendly_date(block.ends_at))
|
||||
else
|
||||
t("user_blocks.helper.until_login")
|
||||
|
|
|
@ -52,6 +52,6 @@ class AccessToken < OauthToken
|
|||
protected
|
||||
|
||||
def set_authorized_at
|
||||
self.authorized_at = Time.now
|
||||
self.authorized_at = Time.now.utc
|
||||
end
|
||||
end
|
||||
|
|
|
@ -71,11 +71,11 @@ class Changeset < ApplicationRecord
|
|||
# note that this may not be a hard limit - due to timing changes and
|
||||
# concurrency it is possible that some changesets may be slightly
|
||||
# longer than strictly allowed or have slightly more changes in them.
|
||||
((closed_at > Time.now.getutc) && (num_changes <= MAX_ELEMENTS))
|
||||
((closed_at > Time.now.utc) && (num_changes <= MAX_ELEMENTS))
|
||||
end
|
||||
|
||||
def set_closed_time_now
|
||||
self.closed_at = Time.now.getutc if is_open?
|
||||
self.closed_at = Time.now.utc if is_open?
|
||||
end
|
||||
|
||||
def self.from_xml(xml, create: false)
|
||||
|
@ -95,7 +95,7 @@ class Changeset < ApplicationRecord
|
|||
def self.from_xml_node(pt, create: false)
|
||||
cs = Changeset.new
|
||||
if create
|
||||
cs.created_at = Time.now.getutc
|
||||
cs.created_at = Time.now.utc
|
||||
# initial close time is 1h ahead, but will be increased on each
|
||||
# modification.
|
||||
cs.closed_at = cs.created_at + IDLE_TIMEOUT
|
||||
|
@ -191,7 +191,7 @@ class Changeset < ApplicationRecord
|
|||
self.closed_at = if (closed_at - created_at) > (MAX_TIME_OPEN - IDLE_TIMEOUT)
|
||||
created_at + MAX_TIME_OPEN
|
||||
else
|
||||
Time.now.getutc + IDLE_TIMEOUT
|
||||
Time.now.utc + IDLE_TIMEOUT
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -70,7 +70,7 @@ class Issue < ApplicationRecord
|
|||
event :resolve do
|
||||
transitions :from => :open, :to => :resolved
|
||||
after do
|
||||
self.resolved_at = Time.now.getutc
|
||||
self.resolved_at = Time.now.utc
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -236,7 +236,7 @@ class Node < ApplicationRecord
|
|||
private
|
||||
|
||||
def save_with_history!
|
||||
t = Time.now.getutc
|
||||
t = Time.now.utc
|
||||
|
||||
self.version += 1
|
||||
self.timestamp = t
|
||||
|
|
|
@ -45,7 +45,7 @@ class Note < ApplicationRecord
|
|||
# Close a note
|
||||
def close
|
||||
self.status = "closed"
|
||||
self.closed_at = Time.now.getutc
|
||||
self.closed_at = Time.now.utc
|
||||
save
|
||||
end
|
||||
|
||||
|
|
|
@ -67,6 +67,6 @@ class Oauth2Verifier < OauthToken
|
|||
def generate_keys
|
||||
self.token = OAuth::Helper.generate_key(20)[0, 20]
|
||||
self.expires_at = 10.minutes.from_now
|
||||
self.authorized_at = Time.now
|
||||
self.authorized_at = Time.now.utc
|
||||
end
|
||||
end
|
||||
|
|
|
@ -52,7 +52,7 @@ class OauthToken < ApplicationRecord
|
|||
end
|
||||
|
||||
def invalidate!
|
||||
update(:invalidated_at => Time.now)
|
||||
update(:invalidated_at => Time.now.utc)
|
||||
end
|
||||
|
||||
def authorized?
|
||||
|
|
|
@ -263,7 +263,7 @@ class Relation < ApplicationRecord
|
|||
private
|
||||
|
||||
def save_with_history!
|
||||
t = Time.now.getutc
|
||||
t = Time.now.utc
|
||||
|
||||
self.version += 1
|
||||
self.timestamp = t
|
||||
|
|
|
@ -42,7 +42,7 @@ class RequestToken < OauthToken
|
|||
return false if authorized?
|
||||
|
||||
self.user = user
|
||||
self.authorized_at = Time.now
|
||||
self.authorized_at = Time.now.utc
|
||||
self.verifier = OAuth::Helper.generate_key(20)[0, 20] unless oauth10?
|
||||
save
|
||||
end
|
||||
|
|
|
@ -37,7 +37,7 @@ class UserBlock < ApplicationRecord
|
|||
##
|
||||
# scope to match active blocks
|
||||
def self.active
|
||||
where("needs_view or ends_at > ?", Time.now.getutc)
|
||||
where("needs_view or ends_at > ?", Time.now.utc)
|
||||
end
|
||||
|
||||
##
|
||||
|
@ -50,7 +50,7 @@ class UserBlock < ApplicationRecord
|
|||
# returns true if the block is currently active (i.e: the user can't
|
||||
# use the API).
|
||||
def active?
|
||||
needs_view || ends_at > Time.now.getutc
|
||||
needs_view || ends_at > Time.now.utc
|
||||
end
|
||||
|
||||
##
|
||||
|
@ -65,7 +65,7 @@ class UserBlock < ApplicationRecord
|
|||
# is the user object who is revoking the ban.
|
||||
def revoke!(revoker)
|
||||
update(
|
||||
:ends_at => Time.now.getutc,
|
||||
:ends_at => Time.now.utc,
|
||||
:revoker_id => revoker.id,
|
||||
:needs_view => false
|
||||
)
|
||||
|
|
|
@ -24,7 +24,7 @@ class UserToken < ApplicationRecord
|
|||
after_initialize :set_defaults
|
||||
|
||||
def expired?
|
||||
expiry < Time.now
|
||||
expiry < Time.now.utc
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
@ -227,7 +227,7 @@ class Way < ApplicationRecord
|
|||
private
|
||||
|
||||
def save_with_history!
|
||||
t = Time.now.getutc
|
||||
t = Time.now.utc
|
||||
|
||||
self.version += 1
|
||||
self.timestamp = t
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue