@@ -12,15 +12,13 @@ public class DataExtractor
1212{
1313 private readonly string _cldrPath ;
1414 private readonly string _nzdPath ;
15- private readonly string _tzresPath ;
1615
1716 private readonly TimeZoneData _data = new ( ) ;
1817
1918 private DataExtractor ( string dataPath )
2019 {
2120 _cldrPath = Path . Combine ( dataPath , "cldr" ) ;
2221 _nzdPath = Path . Combine ( dataPath , "nzd" ) ;
23- _tzresPath = Path . Combine ( dataPath , "tzres" ) ;
2422 }
2523
2624 public static DataExtractor Load ( string dataPath , bool overwrite )
@@ -75,8 +73,7 @@ private void DownloadData(bool overwrite)
7573 {
7674 Task . WaitAll (
7775 DownloadCldrAsync ( overwrite ) ,
78- DownloadNzdAsync ( overwrite ) ,
79- DownloadTZResAsync ( overwrite ) ) ;
76+ DownloadNzdAsync ( overwrite ) ) ;
8077 }
8178
8279 private async Task DownloadCldrAsync ( bool overwrite )
@@ -107,20 +104,6 @@ private async Task DownloadNzdAsync(bool overwrite)
107104 }
108105 }
109106
110- private async Task DownloadTZResAsync ( bool overwrite )
111- {
112- var exists = Directory . Exists ( _tzresPath ) ;
113- if ( overwrite || ! exists )
114- {
115- if ( exists )
116- {
117- Directory . Delete ( _tzresPath , true ) ;
118- }
119-
120- await Downloader . DownloadTZResAsync ( _tzresPath ) ;
121- }
122- }
123-
124107 private void LoadZoneCountries ( )
125108 {
126109 foreach ( var location in _tzdbSource . ZoneLocations ! . OrderBy ( x => GetStandardOffset ( x . ZoneId ) ) . ThenBy ( x => GetDaylightOffset ( x . ZoneId ) ) )
@@ -237,7 +220,13 @@ private IList<string> GetSelectionZones(Instant fromInstant, string[] precedence
237220 }
238221
239222 // use the zone-precedence.txt file when we need a tiebreaker
240- return precedence . Intersect ( ids ) . First ( ) ;
223+ var s = precedence . Intersect ( ids ) . FirstOrDefault ( ) ;
224+ if ( s != null )
225+ {
226+ return s ;
227+ } else {
228+ throw new InvalidOperationException ( "No tiebreaker found for " + string . Join ( ", " , ids ) ) ;
229+ }
241230 } )
242231 . ToList ( ) ;
243232
@@ -510,7 +499,7 @@ private static TimeZoneValues GetTimeZoneValues(XContainer element)
510499
511500 private void LoadDisplayNames ( )
512501 {
513- using var stream = File . OpenRead ( Path . Combine ( _tzresPath , "tzinfo .json" ) ) ;
502+ using var stream = File . OpenRead ( Path . Combine ( "data" , "windows-displaynames .json" ) ) ;
514503 var data = JsonNode . Parse ( stream ) ! ;
515504 var languages = data [ "Languages" ] ;
516505 if ( languages == null )
@@ -607,4 +596,4 @@ private IList<Instant> GetAllZoneSplitPoints()
607596
608597 return list ;
609598 }
610- }
599+ }
0 commit comments