Skip to content

Commit

Permalink
Add explicit require of ./lucky/route_helper before ./lucky/* (#788)
Browse files Browse the repository at this point in the history
* Add explicit require of ./lucky/route_helper before ./lucky/*

* Fix Time.now deprecation warning
  • Loading branch information
bcardiff authored and paulcsmith committed Jun 5, 2019
1 parent 740b716 commit f6d4b97
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion spec/charms/cookie_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ require "../spec_helper"
describe HTTP::Cookie do
describe "setters" do
it "can chain and set values" do
time = Time.now
time = Time.utc
cookie = test_cookie
.name("session_id")
.value("1")
Expand Down
2 changes: 1 addition & 1 deletion spec/lucky/pretty_log_formatter_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ end
private def format(io, data : NamedTuple, severity = Logger::Severity::INFO)
Lucky::PrettyLogFormatter.new(
severity: severity,
timestamp: Time.now,
timestamp: Time.utc,
progname: "",
io: io
).format(data)
Expand Down
4 changes: 2 additions & 2 deletions spec/lucky/time_helpers_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ end
describe Lucky::TimeHelpers do
describe "distance_of_time_in_words" do
it "reports the approximate distance in time between two Time" do
from_time = Time.now
from_time = Time.local
view.distance_of_time_in_words(from_time, from_time + 1.second).should eq "a second"
view.distance_of_time_in_words(from_time, from_time + 10.seconds).should eq "10 seconds"
view.distance_of_time_in_words(from_time, from_time + 1.minute).should eq "a minute"
Expand All @@ -32,7 +32,7 @@ describe Lucky::TimeHelpers do

describe "time_ago_in_words" do
it "returns the distance from now" do
view.time_ago_in_words(Time.now - 13.months).should eq "about a year"
view.time_ago_in_words(Time.local - 13.months).should eq "about a year"
end
end
end
Expand Down
1 change: 1 addition & 0 deletions src/lucky.cr
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ require "./lucky/exceptions"
require "./lucky/response"
require "./lucky/cookies/*"
require "./lucky/secure_headers/*"
require "./lucky/route_helper"
require "./lucky/*"

module Lucky
Expand Down
4 changes: 2 additions & 2 deletions src/lucky/log_handler.cr
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ class Lucky::LogHandler
delegate logger, to: Lucky

def call(context)
time = Time.now
time = Time.utc
log_request_start(context) unless context.hide_from_logs?
call_next(context)
log_request_end(context, duration: Time.now - time) unless context.hide_from_logs?
log_request_end(context, duration: Time.utc - time) unless context.hide_from_logs?
rescue e
log_exception(context, time, e)
raise e
Expand Down
2 changes: 1 addition & 1 deletion src/lucky/page_helpers/time_helpers.cr
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ module Lucky::TimeHelpers
end

def time_ago_in_words(from : Time) : String
distance_of_time_in_words(from, Time.now)
distance_of_time_in_words(from, Time.utc)
end

private def distance_in_days(distance : Int) : String
Expand Down

0 comments on commit f6d4b97

Please sign in to comment.