using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DisplayDate
{
    class DisplayDate
    {
        static void Main(string[] args)
        {
            // Create a blank variable to hold the date.
            DateTime TheDate = new DateTime();

            // Check for a lack of command line arguments.
            if (args.Count() == 0)
                DisplayQuickHelp();

            // Check for a request for help.
            if (args.Contains("/?"))
                DisplayHelp();

            // Set the date to display.
            TheDate = SetDate(args);

            // Configure the optional formatting.
            String Output = ConfigureDate(TheDate, args);

            // Display the result.
            Console.WriteLine("The current date is: " + Output);
        }

        static void DisplayQuickHelp()
        {
            // Display a short help message.
            Console.WriteLine("This utility requires input arguments!");
            Console.WriteLine("Use DisplayDate /? to obtain help information.");

            // Exit the utility after displaying a short help message.
            Environment.Exit(1);
        }

        static void DisplayHelp()
        {
            // Display a description.
            Console.WriteLine("DisplayDate:");
            Console.WriteLine("\tDisplays the selected date in the specified format.");
            Console.WriteLine();

            // Display the command line syntax.
            Console.WriteLine("DisplayDate /Yesterday | /Today | /Tomorrow [/?] " +
                              "[/Long | /Short]");
            Console.WriteLine();

            // Display the individual command line switches.
            Console.WriteLine("\t/Yesterday\tShows yesterday's date.");
            Console.WriteLine("\t/Today\t\tShows today's date.");
            Console.WriteLine("\t/Tomorrow\tShows tomorrow's date.");
            Console.WriteLine("\t/?\t\tDisplays this help message.");
            Console.WriteLine("\t/Long\t\tShows the date in long format.");
            Console.WriteLine("\t/Short\t\tShows the date in short format.");
            Console.WriteLine();

            // Provide an example.
            Console.WriteLine("Example (shows today's date in long format):");
            Console.WriteLine("\tDisplayDate /Today /Long");

            // Exit the utility after displaying help.
            Environment.Exit(0);
        }

        static DateTime SetDate(String[] Arguments)
        {
            // Create a blank date.
            DateTime ReturnDate = new DateTime();

            // Determine which mandatory date the user requested.
            if (Arguments.Contains("/Yesterday"))
                ReturnDate = DateTime.Now.AddDays(-1);
            else if (Arguments.Contains("/Today"))
                ReturnDate = DateTime.Now;
            else if (Arguments.Contains("/Tomorrow"))
                ReturnDate = DateTime.Now.AddDays(1);
            else
                DisplayQuickHelp();

            // Return the result.
            return ReturnDate;
        }

        static String ConfigureDate(DateTime Date, String[] Arguments)
        {
            // Create a default date string.
            String ReturnString = Date.ToLongDateString();

            // Change the date if the user has selected the short date format.
            if (Arguments.Contains("/Short"))
                ReturnString = Date.ToShortDateString();

            // Return the result.
            return ReturnString;
        }
    }
}
