Converted to use Rails Time.zone only to honor app time zone

This commit is contained in:
Priit Tark 2015-04-06 13:47:18 +03:00
parent a42136268f
commit e1041da50f
16 changed files with 34 additions and 31 deletions

View file

@ -29,7 +29,7 @@ class Certificate < ActiveRecord::Base
@cached_status = SIGNED
if parsed_crt.not_before > Time.now.utc && parsed_crt.not_after < Time.now.utc
if parsed_crt.not_before > Time.zone.now.utc && parsed_crt.not_after < Time.zone.now.utc
@cached_status = EXPIRED
end

View file

@ -81,9 +81,9 @@ class Contact < ActiveRecord::Base
end
def destroy_orphans
logger.info "#{Time.now.utc} - Destroying orphaned contacts\n"
logger.info "#{Time.zone.now.utc} - Destroying orphaned contacts\n"
count = find_orphans.destroy_all.count
logger.info "#{Time.now.utc} - Successfully destroyed #{count} orphaned contacts\n"
logger.info "#{Time.zone.now.utc} - Successfully destroyed #{count} orphaned contacts\n"
end
end

View file

@ -49,7 +49,7 @@ class Domain < ActiveRecord::Base
before_create :set_validity_dates
before_save :touch_always_version
def touch_always_version
self.updated_at = Time.now
self.updated_at = Time.zone.now
end
after_save :manage_automatic_statuses
after_save :update_whois_body
@ -205,7 +205,7 @@ class Domain < ActiveRecord::Base
def set_validity_dates
self.registered_at = Time.zone.now
self.valid_from = Date.today
self.valid_from = Time.zone.now.to_date
self.valid_to = valid_from + self.class.convert_period_to_time(period, period_unit)
end

View file

@ -92,7 +92,7 @@ class Epp::Domain < Domain
at[:name] = frame.css('name').text if new_record?
at[:registrar_id] = current_user.registrar.try(:id)
at[:registered_at] = Time.now if new_record?
at[:registered_at] = Time.zone.now if new_record?
period = frame.css('period').text
at[:period] = (period.to_i == 0) ? 1 : period.to_i
@ -593,7 +593,7 @@ class Epp::Domain < Domain
transaction do
kr = keyrelays.build(
pa_date: Time.now,
pa_date: Time.zone.now,
key_data_flags: parsed_frame.css('flags').text,
key_data_protocol: parsed_frame.css('protocol').text,
key_data_alg: parsed_frame.css('alg').text,
@ -632,7 +632,7 @@ class Epp::Domain < Domain
def validate_exp_dates(cur_exp_date)
begin
return if cur_exp_date.to_date == valid_to
return if cur_exp_date.to_date == valid_to.to_date
rescue
add_epp_error('2306', 'curExpDate', cur_exp_date, I18n.t('errors.messages.epp_exp_dates_do_not_match'))
return

View file

@ -45,7 +45,7 @@ class Keyrelay < ActiveRecord::Base
end
def status
if Time.now > expiry
if Time.zone.now > expiry
return 'expired'
else
return 'pending'

View file

@ -12,7 +12,7 @@ class ZonefileSetting < ActiveRecord::Base
def self.generate_zonefile(origin)
filename = "#{origin}.zone"
STDOUT << "#{Time.now.utc} - Generating zonefile #{filename}\n"
STDOUT << "#{Time.zone.now.utc} - Generating zonefile #{filename}\n"
zf = ActiveRecord::Base.connection.execute(
"select generate_zonefile('#{origin}')"
@ -20,7 +20,7 @@ class ZonefileSetting < ActiveRecord::Base
File.open("#{ENV['zonefile_export_dir']}/#{filename}", 'w') { |f| f.write(zf) }
STDOUT << "#{Time.now.utc} - Successfully generated zonefile #{filename}\n"
STDOUT << "#{Time.zone.now.utc} - Successfully generated zonefile #{filename}\n"
end
def to_s

View file

@ -1,7 +1,7 @@
xml.epp_head do
xml.greeting do
xml.svID 'EPP server (EIS)'
xml.svDate Time.now.utc.iso8601
xml.svDate Time.zone.now.utc.iso8601
xml.svcMenu do
xml.version '1.0'
xml.lang 'en'