當前位置: 首頁>>代碼示例>>VB.NET>>正文


VB.NET TimeZoneInfo.IsDaylightSavingTime方法代碼示例

本文整理匯總了VB.NET中System.TimeZoneInfo.IsDaylightSavingTime方法的典型用法代碼示例。如果您正苦於以下問題:VB.NET TimeZoneInfo.IsDaylightSavingTime方法的具體用法?VB.NET TimeZoneInfo.IsDaylightSavingTime怎麽用?VB.NET TimeZoneInfo.IsDaylightSavingTime使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。


在下文中一共展示了TimeZoneInfo.IsDaylightSavingTime方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的VB.NET代碼示例。

示例1: DisplayDateWithTimeZoneName

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
開發者ID:VB.NET開發者,項目名稱:System,代碼行數:6,代碼來源:TimeZoneInfo.IsDaylightSavingTime

輸出:

The time is 1:00 AM on 4/2/2006 Pacific Standard Time

示例2: IIf

Dim unclearDate As Date = #11/4/2007 1:30AM#
' Test if time is ambiguous.
Console.WriteLine("In the {0}, {1} is {2}ambiguous.", _ 
                  TimeZoneInfo.Local.DisplayName, _
                  unclearDate, _
                  IIf(TimeZoneInfo.Local.IsAmbiguousTime(unclearDate), "", "not "))
' Test if time is DST.
Console.WriteLine("In the {0}, {1} is {2}daylight saving time.", _ 
                  TimeZoneInfo.Local.DisplayName, _
                  unclearDate, _
                  IIf(TimeZoneInfo.Local.IsDaylightSavingTime(unclearDate), "", "not "))
Console.WriteLine()    
' Report time as DST if it is either ambiguous or DST.
If TimeZoneInfo.Local.IsAmbiguousTime(unclearDate) OrElse _ 
   TimeZoneInfo.Local.IsDaylightSavingTime(unclearDate) Then
    Console.WriteLine("{0} may be daylight saving time in {1}.", _ 
                      unclearDate, TimeZoneInfo.Local.DisplayName)                                           
End If
開發者ID:VB.NET開發者,項目名稱:System,代碼行數:18,代碼來源:TimeZoneInfo.IsDaylightSavingTime

輸出:

In the (GMT-08:00) Pacific Time (US & Canada), 11/4/2007 1:30:00 AM is ambiguous.
In the (GMT-08:00) Pacific Time (US & Canada), 11/4/2007 1:30:00 AM is not daylight saving time.

11/4/2007 1:30:00 AM may be daylight saving time in (GMT-08:00) Pacific Time (US & Canada).


注:本文中的System.TimeZoneInfo.IsDaylightSavingTime方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。