Skip to content

Commit 3cf382d

Browse files
committedFeb 14, 2015
Added Timezone to env variables. App will now use the configured timezone
Defaulted Timezone to Pacific if no timezone set.
1 parent 9dd11c0 commit 3cf382d

File tree

7 files changed

+18
-5
lines changed

7 files changed

+18
-5
lines changed
 

‎app/models/event.rb

+8
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,14 @@ def unarchive
8888
def current?
8989
! archived?
9090
end
91+
92+
def cfp_opens
93+
opens_at && opens_at.to_s(:long_with_zone)
94+
end
95+
96+
def cfp_closes
97+
closes_at && closes_at.to_s(:long_with_zone)
98+
end
9199
end
92100

93101
# == Schema Information

‎app/views/admin/events/_form.html.haml

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@
1818
%h3 CFP Dates
1919
.form-group
2020
= f.label :opens_at
21-
= f.object.opens_at.to_s(:long_with_zone) unless f.object.opens_at.blank?
21+
= f.object.cfp_opens
2222
= f.text_field :opens_at, value: (f.object.opens_at.blank? ? "" : f.object.opens_at.to_s(:long_with_zone) )
2323
-#%p.help-block Open proposal end date is optional. If you do not provide one the CFP will defer to its state.
2424
.form-group
2525
= f.label :closes_at
26-
= f.object.closes_at.to_s(:long_with_zone) unless f.object.closes_at.blank?
26+
= f.object.cfp_closes
2727
= f.text_field :closes_at, value: (f.object.closes_at.blank? ? "" : f.object.closes_at.to_s(:long_with_zone) )
2828
-#%p.help-block Open proposal end date is optional. If you do not provide one the CFP will defer to its state.
2929
%h3 Event Dates

‎app/views/organizer/events/show.html.haml

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@
2828
%p= link_to "Edit Guidelines", edit_organizer_event_path(:form => "guidelines_form"), class: "btn btn-primary"
2929
%dl.dl-horizontal
3030
%dt CFP Opens:
31-
%dd #{event.opens_at.to_s(:long_with_zone) unless event.opens_at.blank?}
31+
%dd= event.cfp_opens
3232

3333
%dt CFP Closes:
34-
%dd #{event.closes_at.to_s(:long_with_zone) unless event.closes_at.blank?}
34+
%dd= event.cfp_closes
3535

3636
.subset
3737
%dt Days Remaining:

‎config/application.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class Application < Rails::Application
2020

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

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

‎config/environments/development.rb

+2
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,6 @@
3131
config.action_mailer.default_options = {from: 'cfp@example.org'}
3232

3333
I18n.enforce_available_locales = false
34+
35+
config.time_zone = ENV['TIMEZONE'] || "Pacific Time (US & Canada)"
3436
end

‎config/environments/production.rb

+2
Original file line numberDiff line numberDiff line change
@@ -92,4 +92,6 @@
9292
}
9393

9494
config.exceptions_app = self.routes
95+
96+
config.time_zone = ENV['TIMEZONE'] || "Pacific Time (US & Canada)"
9597
end

‎env-sample

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
TIMEZONE=Mountain Time (US & Canada)
12
POSTGRES_USER=me
23
MAIL_HOST=example.com
34
SECRET_TOKEN=cdcc435fa9a91456b0942359c0c62570f17385276cb66ea0903d0f55dbbd8193ad93336c56399858a2e8095f2fc1fc91dbc76edd92d683d65d9ce18a61e98cf0

0 commit comments

Comments
 (0)
Please sign in to comment.