HijriAdjustment Property
Collapse the table of content
Expand the table of content

HijriCalendar.HijriAdjustment Property

Note: This namespace, class, or member is supported only in version 1.1 of the .NET Framework.

Gets or sets the number of days to add or subtract from the calendar to accommodate the variances in the start and the end of Ramadan and to accommodate the date difference between countries/regions.

[Visual Basic]
Public Property HijriAdjustment As Integer
[C#]
public int HijriAdjustment {get; set;}
[C++]
public: __property int get_HijriAdjustment();
public: __property void set_HijriAdjustment(int);
[JScript]
public function get HijriAdjustment() : int;
public function set HijriAdjustment(int);

Property Value

An integer from -2 to 2 that represents the number of days to add or subtract from the calendar.

Exceptions

Exception Type Condition
ArgumentOutOfRangeException The property is being set to an invalid value.

Remarks

This implementation of the HijriCalendar class adjusts the calendar date by adding or subtracting a value from zero to two days to accommodate the variances in the start and the end of Ramadan and to accommodate the date difference between countries/regions. That value is stored in the HijriAdjustment property. If HijriAdjustment is not set explicitly, it derives its value from the settings in Regional and Language Options (or Regional Options or Regional Settings) in Control Panel in Windows and is stored in the registry value HKEY_CURRENT_USER\Control Panel\International\AddHijriDate. However, that information can change during the life of the AppDomain. The HijriCalendar class does not detect changes in the system settings automatically.

Example

[Visual Basic, C#, C++] The following code example shows how HijriAdjustment affects the date.

[Visual Basic] 
Imports System
Imports System.Globalization

Public Class SamplesHijriCalendar

   Public Shared Sub Main()

      ' Creates and initializes a HijriCalendar.
      Dim myCal As New HijriCalendar()

      ' Creates a DateTime and initializes it to the second day of the first month of the year 1422.
      Dim myDT As New DateTime(1422, 1, 2, myCal)

      ' Displays the current values of the DateTime.
      Console.WriteLine("HijriAdjustment is {0}.", myCal.HijriAdjustment)
      Console.WriteLine("   Year is {0}.", myCal.GetYear(myDT))
      Console.WriteLine("   Month is {0}.", myCal.GetMonth(myDT))
      Console.WriteLine("   Day is {0}.", myCal.GetDayOfMonth(myDT))

      ' Sets the HijriAdjustment property to 2.
      myCal.HijriAdjustment = 2
      Console.WriteLine("HijriAdjustment is {0}.", myCal.HijriAdjustment)
      Console.WriteLine("   Year is {0}.", myCal.GetYear(myDT))
      Console.WriteLine("   Month is {0}.", myCal.GetMonth(myDT))
      Console.WriteLine("   Day is {0}.", myCal.GetDayOfMonth(myDT))

      ' Sets the HijriAdjustment property to -2.
      myCal.HijriAdjustment = - 2
      Console.WriteLine("HijriAdjustment is {0}.", myCal.HijriAdjustment)
      Console.WriteLine("   Year is {0}.", myCal.GetYear(myDT))
      Console.WriteLine("   Month is {0}.", myCal.GetMonth(myDT))
      Console.WriteLine("   Day is {0}.", myCal.GetDayOfMonth(myDT))

   End Sub 'Main 

End Class 'SamplesHijriCalendar


'This code produces the following output.  Results vary depending on the registry settings.
'
'HijriAdjustment is 0.
'   Year is 1422.
'   Month is 1.
'   Day is 2.
'HijriAdjustment is 2.
'   Year is 1422.
'   Month is 1.
'   Day is 4.
'HijriAdjustment is -2.
'   Year is 1421.
'   Month is 12.
'   Day is 29.


[C#] 
using System;
using System.Globalization;

public class SamplesHijriCalendar  {

   public static void Main()  {

      // Creates and initializes a HijriCalendar.
      HijriCalendar myCal = new HijriCalendar();

      // Creates a DateTime and initializes it to the second day of the first month of the year 1422.
      DateTime myDT = new DateTime( 1422, 1, 2, myCal );

      // Displays the current values of the DateTime.
      Console.WriteLine( "HijriAdjustment is {0}.", myCal.HijriAdjustment );
      Console.WriteLine( "   Year is {0}.", myCal.GetYear( myDT ) );
      Console.WriteLine( "   Month is {0}.", myCal.GetMonth( myDT ) );
      Console.WriteLine( "   Day is {0}.", myCal.GetDayOfMonth( myDT ) );

      // Sets the HijriAdjustment property to 2.
      myCal.HijriAdjustment = 2;
      Console.WriteLine( "HijriAdjustment is {0}.", myCal.HijriAdjustment );
      Console.WriteLine( "   Year is {0}.", myCal.GetYear( myDT ) );
      Console.WriteLine( "   Month is {0}.", myCal.GetMonth( myDT ) );
      Console.WriteLine( "   Day is {0}.", myCal.GetDayOfMonth( myDT ) );

      // Sets the HijriAdjustment property to -2.
      myCal.HijriAdjustment = -2;
      Console.WriteLine( "HijriAdjustment is {0}.", myCal.HijriAdjustment );
      Console.WriteLine( "   Year is {0}.", myCal.GetYear( myDT ) );
      Console.WriteLine( "   Month is {0}.", myCal.GetMonth( myDT ) );
      Console.WriteLine( "   Day is {0}.", myCal.GetDayOfMonth( myDT ) );

   }

}

/*
This code produces the following output.  Results vary depending on the registry settings.

HijriAdjustment is 0.
   Year is 1422.
   Month is 1.
   Day is 2.
HijriAdjustment is 2.
   Year is 1422.
   Month is 1.
   Day is 4.
HijriAdjustment is -2.
   Year is 1421.
   Month is 12.
   Day is 29.

*/

[C++] 
#using <mscorlib.dll>
using namespace System;
using namespace System::Globalization;

int main()
{
   // Creates and initializes a HijriCalendar.
   HijriCalendar* myCal = new HijriCalendar();

   // Creates a DateTime and initializes it to the second day of the first month of the year 1422.
   DateTime myDT = DateTime(1422, 1, 2, myCal);

   // Displays the current values of the DateTime.
   Console::WriteLine(S"HijriAdjustment is {0}.", __box(myCal -> HijriAdjustment));
   Console::WriteLine(S"   Year is {0}.", __box(myCal -> GetYear(myDT)));
   Console::WriteLine(S"   Month is {0}.", __box(myCal -> GetMonth(myDT)));
   Console::WriteLine(S"   Day is {0}.", __box(myCal -> GetDayOfMonth(myDT)));

   // Sets the HijriAdjustment property to 2.
   myCal -> HijriAdjustment = 2;
   Console::WriteLine(S"HijriAdjustment is {0}.", __box(myCal -> HijriAdjustment));
   Console::WriteLine(S"   Year is {0}.", __box(myCal -> GetYear(myDT)));
   Console::WriteLine(S"   Month is {0}.", __box(myCal -> GetMonth(myDT)));
   Console::WriteLine(S"   Day is {0}.", __box(myCal -> GetDayOfMonth(myDT)));

   // Sets the HijriAdjustment property to -2.
   myCal -> HijriAdjustment = -2;
   Console::WriteLine(S"HijriAdjustment is {0}.", __box(myCal -> HijriAdjustment));
   Console::WriteLine(S"   Year is {0}.", __box(myCal -> GetYear(myDT)));
   Console::WriteLine(S"   Month is {0}.", __box(myCal -> GetMonth(myDT)));
   Console::WriteLine(S"   Day is {0}.", __box(myCal -> GetDayOfMonth(myDT)));
}

/*
This code produces the following output.  Results vary depending on the registry settings.

HijriAdjustment is 0.
Year is 1422.
Month is 1.
Day is 2.
HijriAdjustment is 2.
Year is 1422.
Month is 1.
Day is 4.
HijriAdjustment is -2.
Year is 1421.
Month is 12.
Day is 29.

*/

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

See Also

HijriCalendar Class | HijriCalendar Members | System.Globalization Namespace

Show:
© 2016 Microsoft