Windows Dev Center

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 Value

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

ExceptionCondition
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.

The following code example shows how HijriAdjustment affects the date.


using System;
using System.Globalization;

public class Example
{

   public static void Demo(System.Windows.Controls.TextBlock outputBlock)
   {

      // 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.
      outputBlock.Text += String.Format("HijriAdjustment is {0}.", myCal.HijriAdjustment) + "\n";
      outputBlock.Text += String.Format("   Year is {0}.", myCal.GetYear(myDT)) + "\n";
      outputBlock.Text += String.Format("   Month is {0}.", myCal.GetMonth(myDT)) + "\n";
      outputBlock.Text += String.Format("   Day is {0}.", myCal.GetDayOfMonth(myDT)) + "\n";

      // Sets the HijriAdjustment property to 2.
      myCal.HijriAdjustment = 2;
      outputBlock.Text += String.Format("HijriAdjustment is {0}.", myCal.HijriAdjustment) + "\n";
      outputBlock.Text += String.Format("   Year is {0}.", myCal.GetYear(myDT)) + "\n";
      outputBlock.Text += String.Format("   Month is {0}.", myCal.GetMonth(myDT)) + "\n";
      outputBlock.Text += String.Format("   Day is {0}.", myCal.GetDayOfMonth(myDT)) + "\n";

      // Sets the HijriAdjustment property to -2.
      myCal.HijriAdjustment = -2;
      outputBlock.Text += String.Format("HijriAdjustment is {0}.", myCal.HijriAdjustment) + "\n";
      outputBlock.Text += String.Format("   Year is {0}.", myCal.GetYear(myDT)) + "\n";
      outputBlock.Text += String.Format("   Month is {0}.", myCal.GetMonth(myDT)) + "\n";
      outputBlock.Text += String.Format("   Day is {0}.", myCal.GetDayOfMonth(myDT)) + "\n";

   }

}

/*
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 Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0

Windows Phone

Show:
© 2015 Microsoft