TimeZoneInfo.DaylightName 属性

定义

获取当前时区的夏令时的显示名称。Gets the display name for the current time zone's daylight saving time.

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

属性值

String

时区的夏令时的显示名称。The display name for the time zone's daylight saving time.

示例

下面的示例定义了一个名为 DisplayDateWithTimeZoneName 的方法,该方法使用 IsDaylightSavingTime(DateTime) 方法来确定是显示时区的标准时间名称还是夏时制名称。The following example defines a method named DisplayDateWithTimeZoneName that uses the IsDaylightSavingTime(DateTime) method to determine whether to display a time zone's standard time name or daylight saving time name.

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

注解

显示名称根据 Windows 操作系统中安装的区域性进行了本地化。The display name is localized based on the culture installed with the Windows operating system.

一个 DaylightName 属性,其值不为, String.Empty 或者不 null 一定表示时区支持夏令时。A DaylightName property whose value is not String.Empty or null does not necessarily indicate that the time zone supports daylight saving time. 若要确定时区是否支持夏令时,请检查其属性的值 SupportsDaylightSavingTimeTo determine whether the time zone supports daylight saving time, check the value of its SupportsDaylightSavingTime property.

在大多数情况下, DaylightName 系统定义的时区的属性不是 String.EmptynullIn most cases, the DaylightName property of system-defined time zones is not String.Empty or null. 但是, DaylightName 可以将自定义时区的属性设置为 String.EmptyHowever, the DaylightName property of custom time zones can be set to String.Empty. 当自定义时区由 TimeZoneInfo.CreateCustomTimeZone(String, TimeSpan, String, String)TimeZoneInfo.CreateCustomTimeZone(String, TimeSpan, String, String, String, TimeZoneInfo+AdjustmentRule[], Boolean) 重载创建,并且参数为时,会发生这种情况 disableDaylightSavingTime trueThis occurs when custom time zones are created by the TimeZoneInfo.CreateCustomTimeZone(String, TimeSpan, String, String) or the TimeZoneInfo.CreateCustomTimeZone(String, TimeSpan, String, String, String, TimeZoneInfo+AdjustmentRule[], Boolean) overload and the disableDaylightSavingTime parameter is true. 因此,您的代码不应假定属性的值 DaylightName 不为 null 或为空。Therefore, your code should never assume that the value of the DaylightName property is not null or empty.

DaylightName属性等效于 DaylightName 类的属性 TimeZoneThe DaylightName property is equivalent to the DaylightName property of the TimeZone class.

适用于