TimeZoneInfo.HasSameRules(TimeZoneInfo) 메서드

정의

현재 개체 및 다른 TimeZoneInfo 개체에 같은 조정 규칙이 있는지 여부를 나타냅니다.

public:
 bool HasSameRules(TimeZoneInfo ^ other);
public bool HasSameRules (TimeZoneInfo other);
member this.HasSameRules : TimeZoneInfo -> bool
Public Function HasSameRules (other As TimeZoneInfo) As Boolean

매개 변수

other
TimeZoneInfo

현재 TimeZoneInfo 개체와 비교할 두 번째 개체입니다.

반환

두 표준 시간대에 동일한 조정 규칙과 동일한 기본 오프셋이 있는 경우 true이고 그렇지 않은 경우 false입니다.

예외

other 매개 변수가 null인 경우

예제

일반적으로 Windows의 레지스트리와 Linux 및 macOS의 ICU 라이브러리 에 정의된 여러 표준 시간대는 UTC(협정 세계시)와 동일한 조정 규칙에서 동일한 오프셋을 갖습니다. 다음 예제에서는 이러한 표준 시간대 목록을 콘솔에 표시합니다.

ReadOnlyCollection<TimeZoneInfo> timeZones = TimeZoneInfo.GetSystemTimeZones();
TimeZoneInfo[] timeZoneArray = new TimeZoneInfo[timeZones.Count];
timeZones.CopyTo(timeZoneArray, 0);
// Iterate array from top to bottom
for (int ctr = timeZoneArray.GetUpperBound(0); ctr >= 1; ctr--)
{
   // Get next item from top
   TimeZoneInfo thisTimeZone = timeZoneArray[ctr];
   for (int compareCtr = 0; compareCtr <= ctr - 1; compareCtr++)
   {
      // Determine if time zones have the same rules
      if (thisTimeZone.HasSameRules(timeZoneArray[compareCtr]))
      {
         Console.WriteLine("{0} has the same rules as {1}", 
                           thisTimeZone.StandardName,
                           timeZoneArray[compareCtr].StandardName);
      }
   }
}
let timeZones = TimeZoneInfo.GetSystemTimeZones()
let timeZoneArray = Array.ofSeq timeZones
// Iterate array from top to bottom
for ctr = timeZoneArray.GetUpperBound 0 - 1 downto 0 do
    // Get next item from top
    let thisTimeZone = timeZoneArray[ctr]
    for compareCtr = 0 to ctr - 1 do
        // Determine if time zones have the same rules
        if thisTimeZone.HasSameRules timeZoneArray[compareCtr] then
            printfn $"{thisTimeZone.StandardName} has the same rules as {timeZoneArray[compareCtr].StandardName}"
Dim timeZones As ReadOnlyCollection(Of TimeZoneInfo) = TimeZoneInfo.GetSystemTimeZones()
Dim timeZoneArray(timeZones.Count - 1) As TimeZoneInfo
timeZones.CopyTo(timeZoneArray, 0) 
'Dim arrayPtr As Integer = 1
' Iterate array from top to bottom
For ctr As Integer = timeZoneArray.GetUpperBound(0) To 1 Step -1
   ' Get next item from top
   Dim thisTimeZone As TimeZoneInfo = timeZoneArray(ctr)
   For compareCtr As Integer = 0 To ctr - 1
      ' Determine if time zones have the same rules
      If thisTimeZone.HasSameRules(timeZoneArray(compareCtr)) Then
         Console.WriteLine("{0} has the same rules as {1}", _
                           thisTimeZone.StandardName, _
                           timeZoneArray(compareCtr).StandardName)
      End If                     
   Next      
Next

설명

메서드와 TimeZoneInfo.Equals(TimeZoneInfo) 마찬가지로 메서드는 HasSameRules 두 표준 시간대가 동일한 기본 오프셋(속성에 정의된 BaseUtcOffset 대로)과 동일한 조정 규칙을 갖는지 여부를 나타냅니다. 메서드와 TimeZoneInfo.Equals(TimeZoneInfo) 달리 는 HasSameRules 속성에 정의된 Id 표준 시간대 식별자를 비교하지 않습니다.

적용 대상