Exemple #1
0
        public void TestDateUtilities()
        {
            Console.WriteLine("Testing Date Utilities\nDate Formats\n");
            // tests different forms of date inputs and makes sure they all convert to standard format "dd/mm/yyyy"
            String[] testQuery = { "12-08-2003",
                                   "12th August 2003",
                                   "2003-8-12",
                                   "August 12 2003",
                                   "2003/08/12",
                                   "12/8/2003",
                                   "August 12th 2003",
                                   "12th, August, 2003",
                                   "12-Aug-2003",
                                   "12-Aug-03",
                                   "Aug-12-03",
                                   "12-8-03",
                                   "12/08/03" };
            for (int i = 0; i < testQuery.Length; i++)
            {
                Console.Write(testQuery[i] + " >> " + DateUtilities.DateFormat(testQuery[i]));
                if (DateUtilities.DateFormat(testQuery[i]).Equals("12/08/2003"))
                {
                    Console.Write(" >> OK\n");
                }
                else
                {
                    Console.Write(" >> ERROR\n");
                }
            }
            Console.WriteLine("\nLeap Years\n");
            // Test different date formats and different years for leap years
            String[] leapQuery = { "12-08-2000", "1900/08/12", "12-Aug-04", "12-08-1975" };
            for (int i = 0; i < leapQuery.Length; i++)
            {
                Console.WriteLine(leapQuery [i] + " >> " + DateUtilities.IsLeapYear(leapQuery[i]));
            }
            Console.WriteLine("\nBirthdays\n");
            // Test the birthday utility isBirthday
            DateTime today = DateTime.Now;

            String[] birthdayQuery = { today.Day + "/" + today.Month + "/" + today.Year,
                                       today.Day + "/" + today.Month + "/2008",
                                       today.Day + "/01/" + today.Year,
                                       "1/" + today.Month + "/09" };
            for (int i = 0; i < birthdayQuery.Length; i++)
            {
                Console.WriteLine(birthdayQuery [i] + " >> " + DateUtilities.IsBirthday(birthdayQuery [i]));
            }
            Console.WriteLine("\nZodiac Signs\n");
            // Tests different date formats and the getZodiac method
            String[] zodiacQuery = { "01/01/2000", "01-02-1967", "23rd March 1952", "12-Sep-07" };
            for (int i = 0; i < zodiacQuery.Length; i++)
            {
                Console.WriteLine(zodiacQuery [i] + " >> " + DateUtilities.GetZodiac(zodiacQuery [i]));
            }
        }
Exemple #2
0
        public virtual void DisplayInfo()
        {
            String format = "{0,-15} {1}";             // used to set the layout of the display

            Console.WriteLine(String.Format(format, "ID:", accountID));
            Console.WriteLine(String.Format(format, "Name:", firstName + " " + lastName));
            // Format date of birth .. using the DateUtilities Class methods
            Console.WriteLine(String.Format(format, "Birth Date:", DateUtilities.DateFormat(dob)));
            // Format money using "{0:C}" which formats a number into currency ( e.g $1.00 )
            Console.WriteLine(String.Format(format, "Balance:", String.Format("{0:C}", balance)));
        }