C
Size: a a a
C
V
YS
def cast(timestamp) when is_integer(timestamp) do
if String.length("#{timestamp}") > 10 do
DateTime.from_unix(timestamp, :millisecond)
else
DateTime.from_unix(timestamp)
end
end
V
def cast(timestamp) when is_integer(timestamp) do
if String.length("#{timestamp}") > 10 do
DateTime.from_unix(timestamp, :millisecond)
else
DateTime.from_unix(timestamp)
end
end
ŹR
YS
DateTime.from_unix
с разным кол-ом параметровPG
PG
АН
V
Н
АН
Н
V
DateTime.from_unix
с разным кол-ом параметровV
defmodule D doD.cast(1234567890)
def cast(timestamp) when is_integer(timestamp) do
if String.length("#{timestamp}") > 10 do
DateTime.from_unix(timestamp, :millisecond)
else
DateTime.from_unix(timestamp)
end
end
end
V
cast(timestamp)
- значит либо cast должен корректно работать для всех целых timestamp, либо ты должен ограничить допустимые значения timestamp. Иначе это silent data corruption.V
def cast({:seconds, timestamp}), do: DateTime.from_unix(timestamp)
def cast({:milliseconds, timestamp}), do: DateTime.from_unix(timestamp, :milliseconds)
YS
YS
YS