Skip to content

Commit

Permalink
Fix Kernel.integer_to_binary deprecation
Browse files Browse the repository at this point in the history
  • Loading branch information
rcdilorenzo committed Jun 25, 2014
1 parent 778c684 commit 3399cab
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
20 changes: 10 additions & 10 deletions lib/weber/utils/time.ex
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,17 @@ defmodule Weber.Time do

# Y
def format_time(<<89, rest :: binary>>, locale_pid, result, datetime = {{year, _, _}, _}) do
format_time(rest, locale_pid, result <> integer_to_binary(year), datetime)
format_time(rest, locale_pid, result <> Integer.to_string(year), datetime)
end

# y
def format_time(<<121, rest :: binary>>, locale_pid, result, datetime = {{year, _, _}, _}) do
format_time(rest, locale_pid, result <> integer_to_binary(year - 2000), datetime)
format_time(rest, locale_pid, result <> Integer.to_string(year - 2000), datetime)
end

# C
def format_time(<<67, rest :: binary>>, locale_pid, result, datetime = {{year, _, _}, _}) do
format_time(rest, locale_pid, result <> integer_to_binary(trunc (year / 100) + 1), datetime)
format_time(rest, locale_pid, result <> Integer.to_string(trunc (year / 100) + 1), datetime)
end

# B
Expand All @@ -72,7 +72,7 @@ defmodule Weber.Time do

# m
def format_time(<<109, rest :: binary>>, locale_pid, result, datetime = {{_, month, _}, _}) do
format_time(rest, locale_pid, result <> integer_to_binary(month), datetime)
format_time(rest, locale_pid, result <> Integer.to_string(month), datetime)
end

# A
Expand All @@ -91,28 +91,28 @@ defmodule Weber.Time do

# d
def format_time(<<100, rest :: binary>>, locale_pid, result, datetime = {{_, _, day}, _}) do
format_time(rest, locale_pid, result <> integer_to_binary(day), datetime)
format_time(rest, locale_pid, result <> Integer.to_string(day), datetime)
end

# w
def format_time(<<119, rest :: binary>>, locale_pid, result, datetime = {date, _}) do
day_num = :calendar.day_of_the_week(date)
format_time(rest, locale_pid, result <> integer_to_binary(day_num), datetime)
format_time(rest, locale_pid, result <> Integer.to_string(day_num), datetime)
end

# H
def format_time(<<72, rest :: binary>>, locale_pid, result, datetime = {_, {hour, _, _}}) do
format_time(rest, locale_pid, result <> integer_to_binary(hour), datetime)
format_time(rest, locale_pid, result <> Integer.to_string(hour), datetime)
end

# M
def format_time(<<77, rest :: binary>>, locale_pid, result, datetime = {_, {_, minute, _}}) do
format_time(rest, locale_pid, result <> integer_to_binary(minute), datetime)
format_time(rest, locale_pid, result <> Integer.to_string(minute), datetime)
end

# S
def format_time(<<83, rest :: binary>>, locale_pid, result, datetime = {_, {_, second, _}}) do
format_time(rest, locale_pid, result <> integer_to_binary(second), datetime)
format_time(rest, locale_pid, result <> Integer.to_string(second), datetime)
end

# '
Expand All @@ -125,4 +125,4 @@ defmodule Weber.Time do
format_time(rest, locale_pid, result <> s, datetime)
end

end
end
4 changes: 2 additions & 2 deletions lib/weber/utils/utils.ex
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ defmodule Weber.Utils do
"""
def get_time() do
{{year, month, day}, {hours, minutes, seconds}} = :calendar.local_time()
integer_to_binary(year) <> "." <> integer_to_binary(month) <> "." <> integer_to_binary(day) <> " " <>
integer_to_binary(hours) <> ":" <> integer_to_binary(minutes) <> ":" <> integer_to_binary(seconds) <> " "
Integer.to_string(year) <> "." <> Integer.to_string(month) <> "." <> Integer.to_string(day) <> " " <>
Integer.to_string(hours) <> ":" <> Integer.to_string(minutes) <> ":" <> Integer.to_string(seconds) <> " "
end

@doc """
Expand Down

0 comments on commit 3399cab

Please sign in to comment.