From 1ef2367f652b66f08a2fef87f5231b9922264905 Mon Sep 17 00:00:00 2001 From: jbranchaud Date: Thu, 1 Sep 2016 11:49:12 -0500 Subject: [PATCH] Add Do You Have The Time? as an elixir til --- README.md | 3 ++- elixir/do-you-have-the-time.md | 21 +++++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 elixir/do-you-have-the-time.md diff --git a/README.md b/README.md index 810652d..a033129 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ variety of languages and technologies. These are things that don't really warrant a full blog post. These are mostly things I learn by pairing with smart people at [Hashrocket](http://hashrocket.com/). -_463 TILs and counting..._ +_464 TILs and counting..._ --- @@ -85,6 +85,7 @@ _463 TILs and counting..._ - [Assert An Exception Is Raised](elixir/assert-an-exception-is-raised.md) - [Binary Representation Of A String](elixir/binary-representation-of-a-string.md) - [Create A Date With The Date Sigil](elixir/create-a-date-with-the-date-sigil.md) +- [Do You Have The Time?](elixir/do-you-have-the-time.md) - [Documentation Lookup With Vim And Alchemist](elixir/documentation-lookup-with-vim-and-alchemist.md) - [Dynamically Generating Atoms](elixir/dynamically-generating-atoms.md) - [Execute Raw SQL In An Ecto Migration](elixir/execute-raw-sql-in-an-ecto-migration.md) diff --git a/elixir/do-you-have-the-time.md b/elixir/do-you-have-the-time.md new file mode 100644 index 0000000..552b29a --- /dev/null +++ b/elixir/do-you-have-the-time.md @@ -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" +```