注: 情報がレジストリにない場合、このプロパティは DateTime データ型の最小値を返します。この場合、このプロパティから返された値は不定とみなされます。
レジストリは 2 種類の日付形式をサポートしています。1 つは絶対形式で、これは標準時が始まる正確な日時を指定します。この形式では、年、月、日、時間、分、秒、ミリ秒の各パラメーターを使用して正確な日付を指定します。
もう 1 つは「Day-in-month」形式です。この形式では、年メンバーをゼロ、dayOfWeek メンバーを適切な曜日(平日)に設定し、日メンバーに 1~5 のいずれかの値を設定します。日メンバーの値は、その月の何番目の曜日であるかを示します。この形式を使用すると、4 月の最初の日曜日や、10 月の最後の木曜日(5 が最後を表します)を指定できます。
レジストリに含まれる情報が「day-in-month」形式の場合は、その情報を使用して当年の移行日が計算されます。
Imports Infragistics.Win Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click ' Get an array list of the time zones on this computer Dim timeZones As ArrayList = Infragistics.Win.Utilities.GetTimeZones() If timeZones Is Nothing Then Return ' Iterate the array list and display information on each time zone. Dim i As Int32 Dim crlf As String = vbCrLf Dim tab As String = vbTab For i = 0 To timeZones.Count - 1 Dim tzi As TimeZoneInfo = timeZones(i) Dim info As String = String.Empty info += "Time Zone: " + tzi.StandardName + crlf info += tab + "Daylight Name: " + tzi.DaylightName + crlf info += tab + "Display Name: " + tzi.DisplayName + crlf info += crlf info += tab + "UTC Offset: " + tzi.UtcOffset.TotalHours.ToString() + " hours" + crlf info += tab + "Additional Daylight Saving Time UTC Offset: " + tzi.DaylightUtcOffset.TotalHours.ToString() + " hours" + crlf info += tab + "Additional Standard Time UTC Offset: " + tzi.StandardUtcOffset.TotalHours.ToString() + " hours" + crlf If tzi.DaylightDate <> DateTime.MinValue Then info += tab + "Daylight savings time begins on " + tzi.DaylightDate.ToLongDateString() + crlf End If If tzi.StandardDate <> DateTime.MinValue Then info += tab + "Standard time begins on " + tzi.StandardDate.ToLongDateString() + crlf End If info += crlf info += tab + "The current date is " + tzi.Today.ToLongDateString() + crlf info += tab + "The current time is " + tzi.Now.ToShortTimeString() + crlf info += crlf Dim isDST As Boolean = tzi.IsDaylightSavingTime(DateTime.Now) info += tab + "Daylight savings time is " If Not isDST Then info += "not " End If info += "in effect." + crlf Dim time As DateTime = New DateTime(DateTime.Today.Year, DateTime.Today.Month, DateTime.Today.Day, 9, 0, 0) info += tab + "At 9AM (actual time) in the current time zone, the local time is " + tzi.ToLocalTime(time).ToShortTimeString() + crlf Debug.WriteLine(info) Next End Sub
using Infragistics.Win; using System.Diagnostics; private void button1_Click(object sender, System.EventArgs e) { // Get an array list of the time zones on this computer ArrayList timeZones = Infragistics.Win.Utilities.GetTimeZones(); if ( timeZones == null ) return; // Iterate the array list and display information on each time zone. int i; string crlf = "\r\n"; string tab = "\t"; for ( i = 0; i < timeZones.Count; i ++ ) { TimeZoneInfo tzi = timeZones[i] as TimeZoneInfo; string info = string.Empty; info += "Time Zone: " + tzi.StandardName + crlf; info += tab + "Daylight Name: " + tzi.DaylightName + crlf; info += tab + "Display Name: " + tzi.DisplayName + crlf; info += crlf; info += tab + "UTC Offset: " + tzi.UtcOffset.TotalHours.ToString() + " hours" + crlf; info += tab + "Additional Daylight Saving Time UTC Offset: " + tzi.DaylightUtcOffset.TotalHours.ToString() + " hours" + crlf; info += tab + "Additional Standard Time UTC Offset: " + tzi.StandardUtcOffset.TotalHours.ToString() + " hours" + crlf; if ( tzi.DaylightDate != DateTime.MinValue ) info += tab + "Daylight savings time begins on " + tzi.DaylightDate.ToLongDateString() + crlf; if ( tzi.StandardDate != DateTime.MinValue ) info += tab + "Standard time begins on " + tzi.StandardDate.ToLongDateString() + crlf; info += crlf; info += tab + "The current date is " + tzi.Today.ToLongDateString() + crlf; info += tab + "The current time is " + tzi.Now.ToShortTimeString() + crlf; info += crlf; bool isDST = tzi.IsDaylightSavingTime( DateTime.Now ); info += tab + "Daylight savings time is "; if ( ! isDST ) info += "not "; info += "in effect." + crlf; DateTime time = new DateTime( DateTime.Today.Year, DateTime.Today.Month, DateTime.Today.Day, 9, 0, 0 ); info += tab + "At 9AM (actual time) in the current time zone, the local time is " + tzi.ToLocalTime(time).ToShortTimeString() + crlf; Debug.WriteLine( info ); } }