Date format
Date format
You are encouraged to solve this task according to the task description, using any language you may know.
You are encouraged to solve this task according to the task description, using any language you may know.
Format a given date.
Ada
with Ada.Calendar; use Ada.Calendar; with Ada.Calendar.Arithmetic; use Ada.Calendar.Arithmetic; with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; with Ada.Text_Io; use Ada.Text_IO; procedure Date_Format is type Month_Names is array(Month_Number) of Unbounded_String; Months : constant Month_Names := ( To_Unbounded_String("January"), To_Unbounded_String("February"), To_Unbounded_String("March"), To_Unbounded_String("April"), To_Unbounded_String("May"), To_Unbounded_String("June"), To_Unbounded_String("July"), To_Unbounded_String("August"), To_Unbounded_String("September"), To_Unbounded_String("October"), To_Unbounded_String("November"), To_Unbounded_String("December")); The_Day : Time; Increment : constant Day_Count := 1; begin The_Day := Clock; Put_Line("Today is: " & To_String(Months(Month(The_Day))) & Day_Number'Image(Day(The_Day)) & "," & Year_Number'Image(Year(The_Day))); The_Day := The_Day + Increment; Put_Line("Tomorrow is: " & To_String(Months(Month(The_Day))) & Day_Number'Image(Day(The_Day)) & "," & Year_Number'Image(Year(The_Day))); end Date_Format;
Python
Formatting rules: http://docs.python.org/lib/module-time.html (strftime)
from datetime import * # Print today's date: today = date.today() print "Today is: ", today.strftime('%B %d, %Y') # Print tomorrow's date: tomorrow = today + timedelta( days=1 ) print "Tomorrow is: ", tomorrow.strftime('%B %d, %Y')