From 8940ae0469cfef8d457f7a46ac88f01d74796b75 Mon Sep 17 00:00:00 2001 From: jbranchaud Date: Wed, 7 Sep 2016 20:00:07 -0500 Subject: [PATCH] Add Do You Have The Time? - Part 2 as an elixir til --- README.md | 3 ++- elixir/do-you-have-the-time-part-2.md | 23 +++++++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 elixir/do-you-have-the-time-part-2.md diff --git a/README.md b/README.md index 862ebb5..9f96c54 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/). -_465 TILs and counting..._ +_466 TILs and counting..._ --- @@ -87,6 +87,7 @@ _465 TILs and counting..._ - [Check For A Substring Match](elixir/check-for-a-substring-match.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) +- [Do You Have The Time? - Part 2](elixir/do-you-have-the-time-part-2.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-part-2.md b/elixir/do-you-have-the-time-part-2.md new file mode 100644 index 0000000..76a3f9d --- /dev/null +++ b/elixir/do-you-have-the-time-part-2.md @@ -0,0 +1,23 @@ +# Do You Have The Time? - Part 2 + +In [_Do You Have The +Time?_](https://github.com/jbranchaud/til/blob/master/elixir/do-you-have-the-time.md), +I demonstrated a way of using an Erlang function to get at and work with +time in Elixir. As of Elixir 1.3, there is now a [`Time` +module](http://elixir-lang.org/docs/stable/elixir/Time.html) that provides a +sigil and some functions for working with time. + +We can use Elixir's `Time` module to simplify the example from the previous +iteration of this TIL: + +```elixir +defmodule TickTock do + def current_time do + Time.from_erl!(:erlang.time) + |> Time.to_string + end +end + +> TickTock.current_time +"19:58:12" +```