@@ -138,17 +138,13 @@ private static void LoadServerTimeZones(Xtensive.Sql.SqlConnection connection,
138138 var name = reader . GetString ( 0 ) ;
139139 var abbrev = reader . GetString ( 1 ) ;
140140
141- if ( name . Equals ( "ZULU" , StringComparison . OrdinalIgnoreCase )
142- || abbrev . Equals ( "ZULU" , StringComparison . OrdinalIgnoreCase ) )
143- continue ;
144-
145- if ( TimeZoneInfo . TryConvertIanaIdToWindowsId ( name , out var winAnalogue ) )
141+ if ( TryFindSystemTimeZoneById ( name , out var winAnalogue ) )
146142 timezoneIdsWithWinAnalogueList . Add ( name ) ;
147143 else
148144 timezoneIdsWithoutWinAnalogueList . Add ( name ) ;
149145
150146 if ( abbrev [ 0 ] != '-' && abbrev [ 0 ] != '+' && existing . Add ( abbrev ) ) {
151- if ( TimeZoneInfo . TryConvertIanaIdToWindowsId ( abbrev , out var winAnalogue1 ) )
147+ if ( TryFindSystemTimeZoneById ( abbrev , out var winAnalogue1 ) )
152148 timezoneIdsWithWinAnalogueList . Add ( abbrev ) ;
153149 else
154150 timezoneIdsWithoutWinAnalogueList . Add ( abbrev ) ;
@@ -161,16 +157,13 @@ private static void LoadServerTimeZones(Xtensive.Sql.SqlConnection connection,
161157 while ( reader . Read ( ) ) {
162158 var abbrev = reader . GetString ( 0 ) ;
163159
164- if ( abbrev . Equals ( "ZULU" , StringComparison . OrdinalIgnoreCase ) || ! existing . Add ( abbrev ) )
165- continue ;
166-
167- if ( TimeZoneInfo . TryConvertIanaIdToWindowsId ( abbrev , out var winAnalogue ) )
160+ if ( TryFindSystemTimeZoneById ( abbrev , out var winAnalogue ) )
168161 timezoneIdsWithWinAnalogueList . Add ( abbrev ) ;
169162 else
170163 timezoneIdsWithoutWinAnalogueList . Add ( abbrev ) ;
171164
172- if ( abbrev [ 0 ] != '-' && abbrev [ 0 ] != '+' && existing . Add ( abbrev ) ) {
173- if ( TimeZoneInfo . TryConvertIanaIdToWindowsId ( abbrev , out var winAnalogue1 ) )
165+ if ( existing . Add ( abbrev ) ) {
166+ if ( TryFindSystemTimeZoneById ( abbrev , out var winAnalogue1 ) )
174167 timezoneIdsWithWinAnalogueList . Add ( abbrev ) ;
175168 else
176169 timezoneIdsWithoutWinAnalogueList . Add ( abbrev ) ;
@@ -180,5 +173,21 @@ private static void LoadServerTimeZones(Xtensive.Sql.SqlConnection connection,
180173 timezoneIdsWithoutWinAnalogue = timezoneIdsWithoutWinAnalogueList . ToArray ( ) ;
181174 timezoneIdsWithWinAnalogue = timezoneIdsWithWinAnalogueList . ToArray ( ) ;
182175 }
176+
177+ private static bool TryFindSystemTimeZoneById ( string id , out TimeZoneInfo timeZoneInfo )
178+ {
179+ #if NET8_0_OR_GREATER
180+ return TimeZoneInfo . TryFindSystemTimeZoneById ( id , out timeZoneInfo ) ;
181+ #else
182+ try {
183+ timeZoneInfo = TimeZoneInfo . FindSystemTimeZoneById ( id ) ;
184+ return true ;
185+ }
186+ catch {
187+ timeZoneInfo = null ;
188+ return false ;
189+ }
190+ #endif
191+ }
183192 }
184193}
0 commit comments