All day in this year


/ Published in: Scala
Save to your folder(s)



Copy this code and paste it in your HTML
  1. -module(cal).
  2. -export([main/0]).
  3.  
  4. main() ->
  5. StartSec = calendar:datetime_to_gregorian_seconds({{2009,1,1},{0,0,0}}),
  6. EndSec = calendar:datetime_to_gregorian_seconds({{2009,12,31},{0,0,0}}),
  7. run_calendar(false, StartSec, EndSec).
  8.  
  9. run_calendar(true, _StartSec, _EndSec) ->
  10. init:stop() ;
  11.  
  12. run_calendar(false, CurSec, EndSec) ->
  13. { {Year,Month,Day} ,_Time} = calendar:gregorian_seconds_to_datetime(CurSec),
  14. io:format("~p/~p/~p ~n", [Year,Month,Day]),
  15. NewSec = CurSec + 60*60*24,
  16. run_calendar(NewSec > EndSec, NewSec, EndSec).

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.