Share via


HijriCalendar.HijriAdjustment Property

Microsoft Silverlight will reach end of support after October 2021. Learn more.

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)

Syntax

'Declaration
Public Property HijriAdjustment As Integer
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.

Exceptions

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

Examples

The following code example shows how HijriAdjustment affects the date.

Imports System.Globalization

Public Class Example

   Public Shared Sub Demo(ByVal outputBlock As System.Windows.Controls.TextBlock)

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

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

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

   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.

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.

*/

Version Information

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

Platforms

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