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


VB.NET TimeZone.DaylightName屬性代碼示例

本文整理匯總了VB.NET中System.TimeZone.DaylightName屬性的典型用法代碼示例。如果您正苦於以下問題:VB.NET TimeZone.DaylightName屬性的具體用法?VB.NET TimeZone.DaylightName怎麽用?VB.NET TimeZone.DaylightName使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在System.TimeZone的用法示例。


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

示例1: TimeZoneDemo

' Example of selected TimeZone class elements.
Imports System.Globalization

Module TimeZoneDemo

    Sub Main( )

        Const dataFmt As String = "{0,-30}{1}"
        Const timeFmt As String = "{0,-30}{1:yyyy-MM-dd HH:mm}"

        Console.WriteLine( "This example of selected " & _
            "TimeZone class elements generates the following " & _
            vbCrLf & "output, which varies depending on the " & _
            "time zone in which it is run." & vbCrLf )

        ' Get the local time zone and the current local time and year.
        Dim localZone As TimeZone = TimeZone.CurrentTimeZone
        Dim currentDate As DateTime = DateTime.Now
        Dim currentYear As Integer = currentDate.Year

        ' Display the names for standard time and daylight saving 
        ' time for the local time zone.
        Console.WriteLine( dataFmt, "Standard time name:", _
            localZone.StandardName )
        Console.WriteLine( dataFmt, "Daylight saving time name:", _
            localZone.DaylightName )

        ' Display the current date and time and show if they occur 
        ' in daylight saving time.
        Console.WriteLine( vbCrLf & timeFmt, _
            "Current date and time:", currentDate )
        Console.WriteLine( dataFmt, "Daylight saving time?", _
            localZone.IsDaylightSavingTime( currentDate ) )

        ' Get the current Coordinated Universal Time (UTC) and UTC 
        ' offset.
        Dim currentUTC As DateTime = _
            localZone.ToUniversalTime( currentDate )
        Dim currentOffset As TimeSpan = _
            localZone.GetUtcOffset( currentDate )

        Console.WriteLine( timeFmt, "Coordinated Universal Time:", _
            currentUTC )
        Console.WriteLine( dataFmt, "UTC offset:", currentOffset )

        ' Get the DaylightTime object for the current year.
        Dim daylight As DaylightTime = _
            localZone.GetDaylightChanges( currentYear )

        ' Display the daylight saving time range for the current year.
        Console.WriteLine( vbCrLf & _
            "Daylight saving time for year {0}:", currentYear )
        Console.WriteLine( "{0:yyyy-MM-dd HH:mm} to " & _
            "{1:yyyy-MM-dd HH:mm}, delta: {2}", _
            daylight.Start, daylight.End, daylight.Delta )
    End Sub 
End Module 

'This example of selected TimeZone class elements generates the following
'output, which varies depending on the time zone in which it is run.
'
'Standard time name:           Pacific Standard Time
'Daylight saving time name:    Pacific Daylight Time
'
'Current date and time:        2006-01-06 16:47
'Daylight saving time?         False
'Coordinated Universal Time:   2006-01-07 00:47
'UTC offset:                   -08:00:00
'
'Daylight saving time for year 2006:
'2006-04-02 02:00 to 2006-10-29 02:00, delta: 01:00:00
開發者ID:VB.NET開發者,項目名稱:System,代碼行數:71,代碼來源:TimeZone.DaylightName

示例2: Tester

Public Class Tester
    Public Shared Sub Main
        Dim theZone As TimeZone = TimeZone.CurrentTimeZone
        Dim result As New System.Text.StringBuilder

        result.Append("DaylightName: ").AppendLine( _
           theZone.DaylightName)
        result.Append("StandardName: ").AppendLine( _
           theZone.StandardName)
        result.Append("IsDaylightSavingTime(Now): ").AppendLine( _
           theZone.IsDaylightSavingTime(Now))
        result.Append("GetUtcOffset(Now): ").AppendLine( _
           theZone.GetUtcOffset(Now).ToString())
        result.Append("System time is Local Time: ")
        result.AppendLine(Now.Kind = DateTimeKind.Local)
        result.Append("System time is Universal Coordinated Time: ")
        result.AppendLine(Now.Kind = DateTimeKind.Utc)
        result.Append("System time is Unspecified: ")
        result.AppendLine(Now.Kind = DateTimeKind.Unspecified)

        Console.WriteLine(result.ToString())

    End Sub

End Class
開發者ID:VB程序員,項目名稱:System,代碼行數:25,代碼來源:TimeZone.DaylightName


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