1
0
mirror of https://github.com/jbranchaud/til synced 2026-01-03 07:08:01 +00:00

Add Create A Date With The Date Sigil as an elixir til

This commit is contained in:
jbranchaud
2016-06-28 15:52:41 -05:00
parent 3a2622674b
commit 38e9f27b05
2 changed files with 19 additions and 1 deletions

View File

@@ -0,0 +1,17 @@
# Create A Date With The Date Sigil
Elixir 1.3 introduced a new sigil for creating dates, `~D`. It works in the
same way as Date's
[`new/3`](http://elixir-lang.org/docs/stable/elixir/Date.html#new/3)
function producing the Date struct with each of the date parts.
```elixir
> ~D[2016-01-01]
~D[2016-01-01]
iex(7)> ~D[2016-01-01].year
2016
iex(8)> ~D[2016-01-01].month
1
iex(9)> ~D[2016-01-01].day
1
```