TimeZoneInfo.DaylightName Właściwość

Definicja

Pobiera nazwę wyświetlaną bieżącej strefy czasowej (czas letni).

public:
 property System::String ^ DaylightName { System::String ^ get(); };
public string DaylightName { get; }
member this.DaylightName : string
Public ReadOnly Property DaylightName As String

Wartość właściwości

Nazwa wyświetlana strefy czasowej (czas letni).

Przykłady

W poniższym przykładzie zdefiniowano metodę o nazwie DisplayDateWithTimeZoneName , która używa IsDaylightSavingTime(DateTime) metody w celu określenia, czy ma być wyświetlana nazwa standardowego czasu strefy czasowej, czy nazwa czasu letniego.

private void DisplayDateWithTimeZoneName(DateTime date1, TimeZoneInfo timeZone)
{
   Console.WriteLine("The time is {0:t} on {0:d} {1}", 
                     date1, 
                     timeZone.IsDaylightSavingTime(date1) ?
                         timeZone.DaylightName : timeZone.StandardName);   
}
// The example displays output similar to the following:
//    The time is 1:00 AM on 4/2/2006 Pacific Standard Time
let displayDateWithTimeZoneName (date1: DateTime) (timeZone: TimeZoneInfo) =
    printfn $"The time is {date1:t} on {date1:d} {if timeZone.IsDaylightSavingTime date1 then timeZone.DaylightName else timeZone.StandardName}" 
// The example displays output similar to the following:
//    The time is 1:00 AM on 4/2/2006 Pacific Standard Time
Private Sub DisplayDateWithTimeZoneName(date1 As Date, timeZone As TimeZoneInfo)
   Console.WriteLine("The time is {0:t} on {0:d} {1}", _
                     date1, _
                     IIf(timeZone.IsDaylightSavingTime(date1), _
                         timezone.DaylightName, timezone.StandardName))   
End Sub
' The example displays output similar to the following:
'    The time is 1:00 AM on 4/2/2006 Pacific Standard Time

Uwagi

Nazwa wyświetlana jest lokalizowana na podstawie kultury zainstalowanej z systemem operacyjnym Windows.

Właściwość DaylightName , której wartość nie String.Empty jest lub null nie musi wskazywać, że strefa czasowa obsługuje czas letni. Aby określić, czy strefa czasowa obsługuje czas letni, sprawdź wartość jej SupportsDaylightSavingTime właściwości.

W większości przypadków DaylightName właściwość stref czasowych zdefiniowanych przez system nie String.Empty jest lub null. Jednak DaylightName właściwość niestandardowych stref czasowych można ustawić na String.Emptywartość . Dzieje się tak, gdy niestandardowe strefy czasowe są tworzone przez TimeZoneInfo.CreateCustomTimeZone(String, TimeSpan, String, String) przeciążenie lub TimeZoneInfo.CreateCustomTimeZone(String, TimeSpan, String, String, String, TimeZoneInfo+AdjustmentRule[], Boolean) i disableDaylightSavingTime parametr ma wartość true. W związku z tym kod nigdy nie powinien zakładać, że wartość DaylightName właściwości nie jest pusta ani nie null jest pusta.

Właściwość DaylightName jest równoważna DaylightName właściwości klasy TimeZone .

Dotyczy