HijriCalendar.HijriAdjustment Proprietà
Definizione
Importante
Alcune informazioni sono relative alla release non definitiva del prodotto, che potrebbe subire modifiche significative prima della release definitiva. Microsoft non riconosce alcuna garanzia, espressa o implicita, in merito alle informazioni qui fornite.
Ottiene o imposta il numero di giorni da aggiungere o sottrarre dal calendario per riflettere le variazioni dell'inizio e della fine del Ramadan e per tenere conto delle differenze nelle date tra i vari paesi.
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
Valore della proprietà
Valore intero compreso tra -2 e 2 che rappresenta il numero di giorni da aggiungere o sottrarre dal calendario.
Eccezioni
La proprietà viene impostata su un valore non valido.
Esempio
Nell'esempio di codice seguente viene illustrato come HijriAdjustment influisce sulla data.
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.
Commenti
Questa implementazione della classe regola la data del calendario aggiungendo o sottraendo un valore da zero a due giorni per soddisfare le varianza nell'inizio e la fine del HijriCalendar Ramadan e per soddisfare la differenza di data tra paesi/aree geografiche. Tale valore viene archiviato nella HijriAdjustment proprietà . Se HijriAdjustment non è impostato in modo esplicito, deriva il valore dalle impostazioni nella parte delle opzioni internazionali e della lingua di Pannello di controllo e viene archiviato nel valore del Registro di sistema HKEY_CURRENT_USER\Control Panel\International\AddHijriDate. Tuttavia, queste informazioni possono cambiare durante la vita di AppDomain. La HijriCalendar classe non rileva automaticamente le modifiche apportate alle impostazioni di sistema.