HijriCalendar.HijriAdjustment Vlastnost

Definice

Získá nebo nastaví počet dnů, které se mají přičíst nebo odečíst z kalendáře, aby se přizpůsobily odchylky na začátku a konci ramadánu a aby se přizpůsobily rozdílu kalendářních dat mezi zeměmi/oblastmi.

public:
 property int HijriAdjustment { int get(); void set(int value); };
public int HijriAdjustment { get; set; }
member this.HijriAdjustment : int with get, set
Public Property HijriAdjustment As Integer

Hodnota vlastnosti

Celé číslo od -2 do 2, které představuje počet dnů, které se mají přičíst nebo odečíst z kalendáře.

Výjimky

Vlastnost se nastavuje na neplatnou hodnotu.

Příklady

Následující příklad kódu ukazuje, jak HijriAdjustment ovlivňuje datum.

using namespace System;
using namespace System::Globalization;
int main()
{
   
   // Creates and initializes a HijriCalendar.
   HijriCalendar^ myCal = gcnew 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( "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.

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

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

End Class


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

Poznámky

Tato implementace HijriCalendar třídy upraví kalendářní datum tak, že přičte nebo odečte hodnotu od nuly do dvou dnů, aby se přizpůsobily odchylkám v začátku a konci ramadánu a aby se přizpůsobily rozdílu kalendářních dat mezi zeměmi/oblastmi. Tato hodnota je uložena HijriAdjustment ve vlastnosti. Pokud HijriAdjustment není nastaven explicitně, odvozuje svou hodnotu z nastavení v místní a jazykové části Ovládací panely a je uložena v hodnotě registru HKEY_CURRENT_USER\Control Panel\International\AddHijriDate. Tyto informace se však mohou během životnosti AppDomainnástroje změnit. Třída HijriCalendar automaticky nezjistí změny v nastavení systému.

Platí pro