E-Lite 2010: Erlang Behaviours
Nov 7, 2010
Intro to Erlang: Format a Date and Time
 % Declare module name and externally callable functions
 -export([report_time/1, report_time/0]).

 % RFC 867 DayTime server as a function
 % Tuesday, February 22, 1982 18:45:59-PST

 % Macro for a tuple of the month names
 -define(MONTH_NAMES, {"January", "February", "March", "April", "May", "June",
                       "July", "August", "September", "October", "November", "December"}).

 % Function to request the current Date and Time as a binary string
 report_time(_IgnoreArgList) ->

 report_time() ->
   {{Yr, Mo, Day} = Date, {Hr, Min, Secs} = _Time} = calendar:now_to_datetime(erlang:now()),

   DayName = calendar:day_of_the_week(Date),
   DateOutput = io_lib:format("~s, ~s ~w, ~w ~2..0b:~2..0b:~2..0b~n",
                              [weekday(DayName), month(Mo), Day, Yr, Hr, Min, Secs]),