September 2017 Update
This commit is contained in:
parent
bba7bfd280
commit
ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions
|
|
@ -1,25 +1,23 @@
|
|||
defmodule Date do
|
||||
def iso_date, do: iso_date(:erlang.date)
|
||||
defmodule Date_format do
|
||||
def iso_date, do: Date.utc_today |> Date.to_iso8601
|
||||
|
||||
def iso_date(year, month, day), do: iso_date({year, month, day})
|
||||
def iso_date(year, month, day), do: Date.from_erl!({year, month, day}) |> Date.to_iso8601
|
||||
|
||||
def iso_date(date), do:
|
||||
:io.format("~4b-~2..0B-~2..0B~n", Tuple.to_list(date))
|
||||
def long_date, do: Date.utc_today |> long_date
|
||||
|
||||
def long_date, do: long_date(:erlang.date)
|
||||
def long_date(year, month, day), do: Date.from_erl!({year, month, day}) |> long_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}"
|
||||
@months Enum.zip(1..12, ~w[January February March April May June July August September October November December])
|
||||
|> Map.new
|
||||
@weekdays Enum.zip(1..7, ~w[Monday Tuesday Wednesday Thursday Friday Saturday Sunday])
|
||||
|> Map.new
|
||||
def long_date(date) do
|
||||
weekday = Date.day_of_week(date)
|
||||
"#{@weekdays[weekday]}, #{@months[date.month]} #{date.day}, #{date.year}"
|
||||
end
|
||||
end
|
||||
|
||||
Date.iso_date
|
||||
Date.iso_date(2007,11,10)
|
||||
Date.long_date
|
||||
Date.long_date(2007,11,10)
|
||||
IO.puts Date_format.iso_date
|
||||
IO.puts Date_format.long_date
|
||||
IO.puts Date_format.iso_date(2007,11,10)
|
||||
IO.puts Date_format.long_date(2007,11,10)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue