Skip to content

Commit

Permalink
convert binary timestamps
Browse files Browse the repository at this point in the history
  • Loading branch information
slogsdon committed Apr 2, 2014
1 parent cf3a813 commit 2f80895
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lib/stripe/util.ex
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
defmodule Stripe.Util do
def datetime_from_timestamp(ts) do
def datetime_from_timestamp(ts) when is_binary ts do
ts = case Integer.parse ts do
:error -> 0
{i, _r} -> i
end
datetime_from_timestamp ts
end
def datetime_from_timestamp(ts) when is_number ts do
{{year, month, day}, {hour, minutes, seconds}} = :calendar.gregorian_seconds_to_datetime ts
{{year + 1970, month, day}, {hour, minutes, seconds}}
end
Expand Down

0 comments on commit 2f80895

Please sign in to comment.