Skip to content

Commit 398a94d

Browse files
luisgreg99revgum
luisgreg99
authored andcommitted
update timezone (#76)
1 parent 9610990 commit 398a94d

File tree

5 files changed

+7
-6
lines changed

5 files changed

+7
-6
lines changed

app/controllers/api_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ class ApiController < ApplicationController
22
before_action :set_params
33

44
def hours
5-
dates = @dates.blank? ? [Date.today.strftime("%Y-%m-%d"), Date.today.strftime("%Y-%m-%d")] : @dates.sort
5+
dates = @dates.blank? ? [Time.zone.today.strftime("%Y-%m-%d"), Time.zone.today.strftime("%Y-%m-%d")] : @dates.sort
66
alma = AlmaSpecialHours.new
77
@hours = API::OpenAndSpecialHoursXmlToJsonParser.call(alma.xml_document, dates)
88

app/controllers/widgets_controller.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,13 @@ def html_content
4141
end
4242

4343
def alma_request
44-
dates = [Date.today.strftime("%Y-%m-%d"), (Date.today+6.days).strftime("%Y-%m-%d")]
44+
dates = [Time.zone.today.strftime("%Y-%m-%d"), (Time.zone.today+6.days).strftime("%Y-%m-%d")]
4545
alma = AlmaSpecialHours.new
4646
API::OpenAndSpecialHoursXmlToJsonParser.call(alma.xml_document, dates)
4747
end
4848

4949
def alma_todays_hours_request
50-
dates = [Date.today.strftime("%Y-%m-%d"), Date.today.strftime("%Y-%m-%d")]
50+
dates = [Time.zone.today.strftime("%Y-%m-%d"), Time.zone.today.strftime("%Y-%m-%d")]
5151
alma = AlmaSpecialHours.new
5252
API::OpenAndSpecialHoursXmlToJsonParser.call(alma.xml_document, dates)
5353
end

app/services/api/special_hours_xml_to_json_parser.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def self.closed_all_day?(record)
4848
# - current date is within range [from_date, to_date]
4949
def self.upcoming_date?(from_date, to_date)
5050
date_range = DateTime.parse(from_date)..DateTime.parse(to_date)
51-
date_range === Date.today.beginning_of_day || date_range.first.future?
51+
date_range === Time.zone.today.beginning_of_day || date_range.first.future?
5252
end
5353

5454
def self.get_formatted_dates(day)

config/application.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ module API
2121
class Application < Rails::Application
2222
# Initialize configuration defaults for originally generated Rails version.
2323
config.load_defaults 5.2
24+
config.time_zone = 'Pacific Time (US & Canada)'
2425

2526
# Settings in config/environments/* take precedence over those specified here.
2627
# Application configuration can go into files in config/initializers

spec/controllers/api_controller_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
let(:url) { "#{ENV['ALMA_OPEN_HOURS_URL']}?apikey=#{ENV['ALMA_API_KEY']}&from=#{date_from}&to=#{date_to}" }
1212
let(:open_and_special_hours_url) { "#{ENV['ALMA_SPECIAL_HOURS_URL']}?apikey=#{ENV['ALMA_API_KEY']}&scope=#{ENV['ALMA_SPECIAL_HOURS_SCOPE']}" }
1313
let(:xml) { File.read("spec/fixtures/alma_open_hours.xml") }
14-
let(:date_from) { Date.today.strftime("%Y-%m-%d") }
15-
let(:date_to) { Date.today.strftime("%Y-%m-%d") }
14+
let(:date_from) { Time.zone.today.strftime("%Y-%m-%d") }
15+
let(:date_to) { Time.zone.today.strftime("%Y-%m-%d") }
1616
let(:dates) { [date_from, date_to] }
1717
let(:cached_minutes) { "1" }
1818

0 commit comments

Comments
 (0)