From e30c4bb8313a1eea31014ec25292599b6f1e44e4 Mon Sep 17 00:00:00 2001 From: Jeff Browning Date: Tue, 15 Mar 2016 13:38:04 -0400 Subject: [PATCH] Drop Timex dependency in favor of native Erlang --- lib/extwitter/api/base.ex | 7 ++++++- mix.exs | 1 - 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/extwitter/api/base.ex b/lib/extwitter/api/base.ex index 2fcc608..dbd4259 100644 --- a/lib/extwitter/api/base.ex +++ b/lib/extwitter/api/base.ex @@ -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 _ -> @@ -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 diff --git a/mix.exs b/mix.exs index 51671d9..bd18261 100644 --- a/mix.exs +++ b/mix.exs @@ -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]},