1
0
mirror of https://github.com/jbranchaud/til synced 2026-01-04 23:58:01 +00:00

Add Do You Have The Time? as an elixir til

This commit is contained in:
jbranchaud
2016-09-01 11:49:12 -05:00
parent 3ce35c97cc
commit 1ef2367f65
2 changed files with 23 additions and 1 deletions

View File

@@ -0,0 +1,21 @@
# Do You Have The Time?
Elixir doesn't come with any standard ways of getting at or working with
time. There are packages like [Timex](https://github.com/bitwalker/timex)
out there that we can pull in to our projects. However, if we don't have
need for a full-featured date/time library, we can opt for a simpler
solution.
Erlang can give us the time.
```elixir
defmodule TickTock do
def current_time do
{hh,mm,ss} = :erlang.time
"#{hh}:#{mm}:#{ss}"
end
end
> TickTock.current_time
"11:47:13"
```