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

*/


Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

XNA Framework

Supported in: Xbox 360, Windows Phone OS 7.0

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

Community Additions

ADD
Show:
© 2014 Microsoft