Skip to content

Commit

Permalink
Merge pull request #43 from pineconellc/drop_timex
Browse files Browse the repository at this point in the history
Drop Timex.Date.now() call in favor of native Erlang
  • Loading branch information
parroty committed Mar 19, 2016
2 parents 32f5927 + e30c4bb commit aa2a67a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
7 changes: 6 additions & 1 deletion lib/extwitter/api/base.ex
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ defmodule ExTwitter.API.Base do
case code do
@error_code_rate_limit_exceeded ->
reset_at = fetch_rate_limit_reset(header)
reset_in = Enum.max([reset_at - Timex.Date.now(:secs), 0])
reset_in = Enum.max([reset_at - now, 0])
raise ExTwitter.RateLimitExceededError,
code: code, message: message, reset_at: reset_at, reset_in: reset_in
_ ->
Expand All @@ -89,4 +89,9 @@ defmodule ExTwitter.API.Base do
{reset_at, _} = Integer.parse(to_string(reset_at_in_string))
reset_at
end

defp now do
{megsec, sec, _microsec} = :os.timestamp
megsec * 1_000_000 + sec
end
end
1 change: 0 additions & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ defmodule ExTwitter.Mixfile do
[
{:oauth, github: "tim/erlang-oauth"},
{:poison, "~> 1.5"},
{:timex, "~> 1.0.0"},
{:exvcr, "~> 0.6", only: :test},
{:excoveralls, "~> 0.4", only: :test},
{:meck, "~> 0.8.2", only: [:dev, :test]},
Expand Down

0 comments on commit aa2a67a

Please sign in to comment.