|
|
Getting the Days in a Month using British and Arabic calendars |
program Project1;
{$APPTYPE CONSOLE}
uses
System.Globalization;
var
myDate : DateTime;
gbCulture : System.Globalization.CultureInfo;
saCulture : System.Globalization.CultureInfo;
gbCal : System.Globalization.Calendar;
saCal : System.Globalization.Calendar;
begin
// Set up a Great Britain English culture & calendar
gbCulture := System.Globalization.CultureInfo.Create('en-GB');
gbCal := gbCulture.Calendar;
// Set up a Saudi Arabia Arabic culture & calendar
saCulture := System.Globalization.CultureInfo.Create('ar-SA');
saCal := saCulture.Calendar;
// Create a DateTime object : use the gbCalendar to control the
// conversion of year, month and day parameter values into the
// number of ticks since 1st January 0001 AD (the internal value)
// Note : Gregorian Calendar is used by default anyway
myDate := DateTime.Create(2004, 12, 8, gbCal); // 8th December 2004
// Now use the British calendar object to display this date
Console.WriteLine('British calendar :');
Console.WriteLine;
Console.WriteLine('Days in month = {0}',
gbCal.GetDaysInMonth(2004, 12).ToString);
Console.WriteLine('Days in year = {0}',
gbCal.GetDaysInYear(2004).ToString);
Console.WriteLine('Months in year = {0}',
gbCal.GetMonthsInYear(2004).ToString);
// Now use the Arabic calendar object to display this date
Console.WriteLine;
Console.WriteLine('Arabic calendar :');
Console.WriteLine;
Console.WriteLine('Days in month = {0}',
saCal.GetDaysInMonth(2004, 12).ToString);
Console.WriteLine('Days in year = {0}',
saCal.GetDaysInYear(2004).ToString);
Console.WriteLine('Months in year = {0}',
saCal.GetMonthsInYear(2004).ToString);
Console.ReadLine;
end.
| Show full unit code | British calendar :
Days in month = 31
Days in year = 366
Months in year = 12
Arabic calendar :
Days in month = 30
Days in year = 355
Months in year = 12
|
|
|
|