TimeZoneInfo.TransitionTime.CreateFixedDateRule(DateTime, Int32, Int32) Método
Definição
Define uma alteração de tempo que usa uma regra de data fixa (ou seja, uma alteração de tempo que ocorre em um dia específico de um mês específico).Defines a time change that uses a fixed-date rule (that is, a time change that occurs on a specific day of a specific month).
public:
static TimeZoneInfo::TransitionTime CreateFixedDateRule(DateTime timeOfDay, int month, int day);
public static TimeZoneInfo.TransitionTime CreateFixedDateRule (DateTime timeOfDay, int month, int day);
static member CreateFixedDateRule : DateTime * int * int -> TimeZoneInfo.TransitionTime
Public Shared Function CreateFixedDateRule (timeOfDay As DateTime, month As Integer, day As Integer) As TimeZoneInfo.TransitionTime
Parâmetros
- timeOfDay
- DateTime
A hora na qual ocorre a alteração de hora.The time at which the time change occurs. Esse parâmetro corresponde à propriedade TimeOfDay.This parameter corresponds to the TimeOfDay property.
- month
- Int32
O mês em que ocorre uma alteração temporal.The month in which the time change occurs. Esse parâmetro corresponde à propriedade Month.This parameter corresponds to the Month property.
- day
- Int32
O dia do mês no qual ocorrerá a alteração de horário.The day of the month on which the time change occurs. Esse parâmetro corresponde à propriedade Day.This parameter corresponds to the Day property.
Retornos
Dados sobre a alteração de hora.Data about the time change.
Exceções
O parâmetro timeOfDay tem um componente de data não padrão.The timeOfDay parameter has a non-default date component.
- ou --or-
No parâmetro timeOfDay, a propriedade Kind não é Unspecified.The timeOfDay parameter's Kind property is not Unspecified.
- ou --or-
O parâmetro timeOfDay não representa um número inteiro de milissegundos.The timeOfDay parameter does not represent a whole number of milliseconds.
O parâmetro month é menor que 1 ou maior que 12.The month parameter is less than 1 or greater than 12.
- ou --or-
O parâmetro day é menor que 1 ou maior que 31.The day parameter is less than 1 or greater than 31.
Exemplos
O exemplo a seguir cria transições de fuso horário para um fuso horário imaginário usando uma regra de data fixa e uma regra de data flutuante.The following example creates time zone transitions for an imaginary time zone by using both a fixed-date rule and a floating-date rule. A regra de data fixa define um ajuste de fuso horário que começa às 2:00 da manhãThe fixed-date rule defines a time zone adjustment that starts at 2:00 A.M. em 15 de março e termina às 3:00 A.M.on March 15 and ends at 3:00 A.M. em 15 de novembro durante os anos de 1900 a 1955.on November 15 for the years 1900 to 1955.
// Declare necessary TimeZoneInfo.AdjustmentRule objects for time zone
TimeZoneInfo imaginaryTZ;
TimeSpan delta = new TimeSpan(1, 0, 0);
TimeZoneInfo.AdjustmentRule adjustment;
List<TimeZoneInfo.AdjustmentRule> adjustmentList = new List<TimeZoneInfo.AdjustmentRule>();
// Declare transition time variables to hold transition time information
TimeZoneInfo.TransitionTime transitionRuleStart, transitionRuleEnd;
// Define a fictitious new time zone consisting of fixed and floating adjustment rules
// Define fixed rule (for 1900-1955)
transitionRuleStart = TimeZoneInfo.TransitionTime.CreateFixedDateRule(new DateTime(1, 1, 1, 2, 0, 0), 3, 15);
transitionRuleEnd = TimeZoneInfo.TransitionTime.CreateFixedDateRule(new DateTime(1, 1, 1, 3, 0, 0), 11, 15);
adjustment = TimeZoneInfo.AdjustmentRule.CreateAdjustmentRule(new DateTime(1900, 1, 1), new DateTime(1955, 12, 31),
delta, transitionRuleStart, transitionRuleEnd);
adjustmentList.Add(adjustment);
// Define floating rule (for 1956- )
transitionRuleStart = TimeZoneInfo.TransitionTime.CreateFloatingDateRule(new DateTime(1, 1, 1, 2, 0, 0), 3, 5, DayOfWeek.Sunday);
transitionRuleEnd = TimeZoneInfo.TransitionTime.CreateFloatingDateRule(new DateTime(1, 1, 1, 3, 0, 0), 10, 4, DayOfWeek.Sunday);
adjustment = TimeZoneInfo.AdjustmentRule.CreateAdjustmentRule(new DateTime(1956, 1, 1), DateTime.MaxValue.Date, delta, transitionRuleStart, transitionRuleEnd);
adjustmentList.Add(adjustment);
// Create fictitious time zone
imaginaryTZ = TimeZoneInfo.CreateCustomTimeZone("Fictitious Standard Time", new TimeSpan(-9, 0, 0),
"(GMT-09:00) Fictitious Time", "Fictitious Standard Time",
"Fictitious Daylight Time", adjustmentList.ToArray());
' Declare necessary TimeZoneInfo.AdjustmentRule objects for time zone
Dim imaginaryTZ As TimeZoneInfo
Dim delta As New TimeSpan(1, 0, 0)
Dim adjustment As TimeZoneInfo.AdjustmentRule
Dim adjustmentList As New List(Of TimeZoneInfo.AdjustmentRule)
' Declare transition time variables to hold transition time information
Dim transitionRuleStart, transitionRuleEnd As TimeZoneInfo.TransitionTime
' Define a fictitious new time zone consisting of fixed and floating adjustment rules
' Define fixed rule (for 1900-1955)
transitionRuleStart = TimeZoneInfo.TransitionTime.CreateFixedDateRule(#2:00:00AM#, 3, 15)
transitionRuleEnd = TimeZoneInfo.TransitionTime.CreateFixedDateRule(#3:00:00AM#, 11, 15)
adjustment = TimeZoneInfo.AdjustmentRule.CreateAdjustmentRule(#1/1/1900#, #12/31/1955#, delta, _
transitionRuleStart, transitionRuleEnd)
adjustmentList.Add(adjustment)
' Define floating rule (for 1956- )
transitionRuleStart = TimeZoneInfo.TransitionTime.CreateFloatingDateRule(#02:00:00AM#, 3, 5, DayOfWeek.Sunday)
transitionRuleEnd = TimeZoneInfo.TransitionTime.CreateFloatingDateRule(#03:00:00AM#, 10, 4, DayOfWeek.Sunday)
adjustment = TimeZoneInfo.AdjustmentRule.CreateAdjustmentRule(#01/01/1956#, Date.MaxValue.Date, delta, transitionRuleStart, transitionRuleEnd)
adjustmentList.Add(adjustment)
' Create fictitious time zone
imaginaryTZ = TimeZoneInfo.CreateCustomTimeZone("Fictitious Standard Time", New TimeSpan(-9, 0, 0), _
"(GMT-09:00) Fictitious Time", "Fictitious Standard Time", _
"Fictitious Daylight Time", adjustmentList.ToArray())
Comentários
Esse método cria uma regra de data fixa (ou seja, uma alteração de tempo que ocorre em um dia específico de um mês específico).This method creates a fixed-date rule (that is, a time change that occurs on a specific day of a specific month). Por exemplo, uma alteração de tempo que sempre ocorre em 28 de outubro segue uma regra de data fixa.For example, a time change that always occurs on October 28 follows a fixed-date rule.
Para transições do horário padrão até o horário de verão, o timeOfDay argumento representa a hora da transição no horário padrão do fuso horário.For transitions from standard time to daylight saving time, the timeOfDay argument represents the time of the transition in the time zone's standard time. Para transições do horário de verão para o horário padrão, ela representa a hora da transição no horário de Verão do fuso horário.For transitions from daylight saving time to standard time, it represents the time of the transition in the time zone's daylight saving time. Observe que se trata de um DateTime valor cujo ano, mês e valores de data devem ser iguais a 1.Note that this is a DateTime value whose year, month, and date values must all equal 1.