VB.Net Tutorial/Date Time/TimeZone

Материал из VB Эксперт
Перейти к: навигация, поиск

Time zone: DateTimeKind.Local, DateTimeKind.Utc, DateTimeKind.Unspecified

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
DaylightName: Pacific Daylight Time
StandardName: Pacific Standard Time
IsDaylightSavingTime(Now): True
GetUtcOffset(Now): -07:00:00
System time is Local Time: True
System time is Universal Coordinated Time: False
System time is Unspecified: False