Another update from ingydotnet^djgoku
This commit is contained in:
parent
91df62d461
commit
948b86eafa
7604 changed files with 108452 additions and 22726 deletions
25
Task/Date-format/Elixir/date-format.elixir
Normal file
25
Task/Date-format/Elixir/date-format.elixir
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
defmodule Date do
|
||||
def iso_date, do: iso_date(:erlang.date)
|
||||
|
||||
def iso_date(year, month, day), do: iso_date({year, month, day})
|
||||
|
||||
def iso_date(date), do:
|
||||
:io.format("~4b-~2..0B-~2..0B~n", Tuple.to_list(date))
|
||||
|
||||
def long_date, do: long_date(:erlang.date)
|
||||
|
||||
def long_date(year, month, day), do: long_date({year, month, day})
|
||||
|
||||
def long_date(date = {year, month, day}) do
|
||||
months = { "January", "February", "March", "April", "May", "June",
|
||||
"July", "August", "September", "October", "November", "December" }
|
||||
weekdays = { "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday" }
|
||||
weekday = :calendar.day_of_the_week(date)
|
||||
IO.puts "#{elem(weekdays, weekday-1)}, #{elem(months, month-1)} #{day}, #{year}"
|
||||
end
|
||||
end
|
||||
|
||||
Date.iso_date
|
||||
Date.iso_date(2007,11,10)
|
||||
Date.long_date
|
||||
Date.long_date(2007,11,10)
|
||||
Loading…
Add table
Add a link
Reference in a new issue