Aracılığıyla paylaş


TimeZoneInfo.TransitionTime.TimeOfDay Özellik

Tanım

Saat değişikliğinin gerçekleştiği saati, dakikayı ve saniyeyi alır.

public:
 property DateTime TimeOfDay { DateTime get(); };
public DateTime TimeOfDay { get; }
member this.TimeOfDay : DateTime
Public ReadOnly Property TimeOfDay As DateTime

Özellik Değeri

Saat değişikliğinin gerçekleştiği günün saati.

Örnekler

Aşağıdaki örnek, yerel bilgisayarda bulunan saat dilimlerini numaralandırır ve ayarlama kuralları olan saat dilimleri için geçiş zamanı bilgilerini görüntüler. Saat bilgileri, değişikliğin gerçekleştiği günün saatini içerir.

private enum WeekOfMonth
{
   First = 1,
   Second = 2,
   Third = 3,
   Fourth = 4,
   Last = 5,
}

public void GetAllTransitionTimes()
{
   ReadOnlyCollection<TimeZoneInfo> timeZones = TimeZoneInfo.GetSystemTimeZones();
   DateTimeFormatInfo dateInfo = CultureInfo.CurrentCulture.DateTimeFormat;
   
   foreach (TimeZoneInfo zone in timeZones)
   {
      Console.WriteLine("{0} transition time information:", zone.StandardName);
      TimeZoneInfo.AdjustmentRule[] adjustmentRules= zone.GetAdjustmentRules();
      
      // Indicate that time zone has no adjustment rules
      if (adjustmentRules.Length == 0)
      { 
         Console.WriteLine("   No adjustment rules defined.");
      }   
      else
      {
         // Iterate adjustment rules       
         foreach (TimeZoneInfo.AdjustmentRule adjustmentRule in adjustmentRules)
         {
            Console.WriteLine("   Adjustment rule from {0:d} to {1:d}:", 
                              adjustmentRule.DateStart, 
                              adjustmentRule.DateEnd);                                 
            
            // Get start of transition
            TimeZoneInfo.TransitionTime daylightStart = adjustmentRule.DaylightTransitionStart;
            // Display information on fixed date rule
            if (! daylightStart.IsFixedDateRule)
               Console.WriteLine("      Begins at {0:t} on the {1} {2} of {3}.", 
                              daylightStart.TimeOfDay, 
                              ((WeekOfMonth)daylightStart.Week).ToString(),  
                              daylightStart.DayOfWeek.ToString(), 
                              dateInfo.GetMonthName(daylightStart.Month));
            // Display information on floating date rule 
            else
               Console.WriteLine("      Begins at {0:t} on the {1} {2} of {3}.", 
                                 daylightStart.TimeOfDay, 
                                 ((WeekOfMonth)daylightStart.Week).ToString(),  
                                 daylightStart.DayOfWeek.ToString(), 
                                 dateInfo.GetMonthName(daylightStart.Month));
            
            // Get end of transition
            TimeZoneInfo.TransitionTime daylightEnd = adjustmentRule.DaylightTransitionEnd;
            // Display information on fixed date rule
            if (! daylightEnd.IsFixedDateRule)
               Console.WriteLine("      Ends at {0:t} on the {1} {2} of {3}.", 
                              daylightEnd.TimeOfDay, 
                              ((WeekOfMonth)daylightEnd.Week).ToString(),  
                              daylightEnd.DayOfWeek.ToString(), 
                              dateInfo.GetMonthName(daylightEnd.Month));
            // Display information on floating date rule
            else
               Console.WriteLine("      Ends at {0:t} on the {1} {2} of {3}.", 
                                 daylightStart.TimeOfDay, 
                                 ((WeekOfMonth)daylightStart.Week).ToString(),  
                                 daylightStart.DayOfWeek.ToString(), 
                                 dateInfo.GetMonthName(daylightStart.Month));
         }
      }   
   }   
}
type WeekOfMonth =
    | First = 1
    | Second = 2
    | Third = 3
    | Fourth = 4
    | Last = 5

let getAllTransitionTimes () =
    let timeZones = TimeZoneInfo.GetSystemTimeZones()
    let dateInfo = CultureInfo.CurrentCulture.DateTimeFormat
    
    for zone in timeZones do
        printfn $"{zone.StandardName} transition time information:"
        let adjustmentRules= zone.GetAdjustmentRules()
        
        // Indicate that time zone has no adjustment rules
        if adjustmentRules.Length = 0 then
            printfn "   No adjustment rules defined."
        else
            // Iterate adjustment rules       
            for adjustmentRule in adjustmentRules do
                printfn $"   Adjustment rule from {adjustmentRule.DateStart:d} to {adjustmentRule.DateEnd:d}:"                                 
                
                // Get start of transition
                let daylightStart = adjustmentRule.DaylightTransitionStart
                // Display information on fixed date rule
                if not daylightStart.IsFixedDateRule then
                    printfn $"      Begins at {daylightStart.TimeOfDay:t} on the {enum<WeekOfMonth> daylightStart.Week} {daylightStart.DayOfWeek} of {dateInfo.GetMonthName daylightStart.Month}."
                // Display information on floating date rule 
                else
                    printfn $"      Begins at {daylightStart.TimeOfDay:t} on the {enum<WeekOfMonth> daylightStart.Week} {daylightStart.DayOfWeek} of {dateInfo.GetMonthName daylightStart.Month}."
                
                // Get end of transition
                let daylightEnd = adjustmentRule.DaylightTransitionEnd
                // Display information on fixed date rule
                if not daylightEnd.IsFixedDateRule then
                    printfn $"      Ends at {daylightEnd.TimeOfDay:t} on the {enum<WeekOfMonth> daylightEnd.Week} {daylightEnd.DayOfWeek} of {dateInfo.GetMonthName daylightEnd.Month}."
                // Display information on floating date rule
                else
                    printfn $"      Ends at {daylightStart.TimeOfDay:t} on the {enum<WeekOfMonth> daylightStart.Week} {daylightStart.DayOfWeek} of {dateInfo.GetMonthName daylightStart.Month}."
Private Enum WeekOfMonth As Integer
   First = 1
   Second = 2
   Third = 3
   Fourth = 4
   Last = 5 
End Enum

Sub GetAllTransitionTimes()
   Dim timeZones As ReadOnlyCollection(Of TimeZoneInfo) = TimeZoneInfo.GetSystemTimeZones()
   For Each zone As TimeZoneInfo In timeZones
      Console.WriteLine("{0} transition time information:", zone.StandardName)
      Dim adjustmentRules() As TimeZoneInfo.AdjustmentRule = zone.GetAdjustmentRules()
      
      ' Indicate that time zone has no adjustment rules
      If adjustmentRules.Length = 0 Then 
         Console.WriteLine("   No adjustment rules defined.")
      Else
         ' Iterate adjustment rules       
         For Each adjustmentRule As TimeZoneInfo.AdjustmentRule in adjustmentRules
            Console.WriteLine("   Adjustment rule from {0:d} to {1:d}:", _
                              adjustmentRule.DateStart, _
                              adjustmentRule.DateEnd)                                 
            
            ' Get start of transition
            Dim daylightStart As TimeZoneInfo.TransitionTime = adjustmentRule.DaylightTransitionStart
            ' Display information on fixed date rule
            If Not daylightStart.IsFixedDateRule Then
               Console.WriteLine("      Begins at {0:t} on the {1} {2} of {3}.", _
                              daylightStart.TimeOfDay, _
                              CType(daylightStart.Week, WeekOfMonth).ToString(), _ 
                              daylightStart.DayOfWeek.ToString(), _
                              MonthName(daylightStart.Month))
            ' Display information on floating date rule 
            Else
               Console.WriteLine("      Begins at {0:t} on the {1} {2} of {3}.", _
                                 daylightStart.TimeOfDay, _
                                 CType(daylightStart.Week, WeekOfMonth).ToString(), _ 
                                 daylightStart.DayOfWeek.ToString(), _
                                 MonthName(daylightStart.Month))
            End If
            
            ' Get end of transition
            Dim daylightEnd As TimeZoneInfo.TransitionTime = adjustmentRule.DaylightTransitionEnd
            ' Display information on fixed date rule
            If Not daylightEnd.IsFixedDateRule Then
               Console.WriteLine("      Ends at {0:t} on the {1} {2} of {3}.", _
                              daylightEnd.TimeOfDay, _
                              CType(daylightEnd.Week, WeekOfMonth).ToString(), _ 
                              daylightEnd.DayOfWeek.ToString(), _
                              MonthName(daylightEnd.Month))
            ' Display information on floating date rule
            Else
               Console.WriteLine("      Ends at {0:t} on the {1} {2} of {3}.", _
                                 daylightStart.TimeOfDay, _
                                 CType(daylightStart.Week, WeekOfMonth).ToString(), _ 
                                 daylightStart.DayOfWeek.ToString(), _
                                 MonthName(daylightStart.Month))
            End If                     
         Next
      End If   
   Next   
End Sub

Açıklamalar

Standart saatten yaz saati saatine geçişler için değer, TimeOfDay saat diliminin standart saatinde geçişin saatini temsil eder. Gün ışığından yararlanma saatinden standart saate geçişler için, saat diliminin yaz saati saatine geçişin saatini temsil eder.

TimeOfDay özelliği yalnızca saat değişikliği saatini tanımlar, ancak tarihini tanımlamaz. Tarih, sabit kural değişiklikleri için Month ve Day özellikleri ve kayan Monthkural değişiklikleri için , Weekve DayOfWeek özellikleri tarafından belirlenir. Bu DateTime değerin tarih bileşeni yoksayılır; yıl, ay ve günün değeri her zaman 1'dir.

TimeOfDay özelliği hem sabit tarih hem de kayan tarih geçişleri için kullanılır.

Şunlara uygulanır