Export (0) Print
Expand All

HijriCalendar.HijriAdjustment Property

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.

Namespace: System.Globalization
Assembly: mscorlib (in mscorlib.dll)

public int HijriAdjustment { get; set; }
/** @property */
public int get_HijriAdjustment ()

/** @property */
public void set_HijriAdjustment (int value)

public function get HijriAdjustment () : int

public function set HijriAdjustment (value : int)

Property Value

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

Exception typeCondition

ArgumentOutOfRangeException

The property is being set to an invalid value.

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.

The following code example shows how HijriAdjustment affects the date.

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.

*/

import System.* ;
import System.Globalization.* ;

public class SamplesHijriCalendar
{
    public static void main(String[] args)
    {
        // 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}.", 
            System.Convert.ToString(myCal.get_HijriAdjustment()));
        Console.WriteLine("   Year is {0}.", 
            System.Convert.ToString(myCal.GetYear(myDT)));
        Console.WriteLine("   Month is {0}.", 
            System.Convert.ToString(myCal.GetMonth(myDT)));
        Console.WriteLine("   Day is {0}.", 
            System.Convert.ToString(myCal.GetDayOfMonth(myDT)));

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

        // Sets the HijriAdjustment property to -2.
        myCal.set_HijriAdjustment(-2);
        Console.WriteLine("HijriAdjustment is {0}.", 
            System.Convert.ToString(myCal.get_HijriAdjustment()));
        Console.WriteLine("   Year is {0}.", 
            System.Convert.ToString(myCal.GetYear(myDT)));
        Console.WriteLine("   Month is {0}.", 
            System.Convert.ToString(myCal.GetMonth(myDT)));
        Console.WriteLine("   Day is {0}.", 
            System.Convert.ToString(myCal.GetDayOfMonth(myDT)));
    } //main 
} //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.
*/

Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0, 1.1

Community Additions

ADD
Show:
© 2014 Microsoft