AcManager.Tools.Helpers.Api.GoogleApiProvider.DetermineTimeZoneAsync C# (CSharp) Метод

DetermineTimeZoneAsync() приватный Метод

private DetermineTimeZoneAsync ( GeoTagsEntry geoTags ) : Task
geoTags AcTools.Utils.Helpers.GeoTagsEntry
Результат Task
        public static async Task<TimeZoneInfo> DetermineTimeZoneAsync(GeoTagsEntry geoTags) {
            var requestUri = string.Format(RequestTimeZoneUri, geoTags.LatitudeValue, geoTags.LongitudeValue,
                                           DateTime.Now.ToUnixTimestamp());
            Logging.Debug(requestUri);

            using (var order = KillerOrder.Create(new WebClient(), 5000)) {
                var data = await order.Victim.DownloadStringTaskAsync(requestUri);
                var doc = XDocument.Parse(data);
                var zoneId = doc.Descendants(@"time_zone_id").FirstOrDefault()?.Value;
                if (zoneId == null) throw new Exception("Invalid response");

                try {
                    return TimeZoneInfo.FindSystemTimeZoneById(zoneId);
                } catch (TimeZoneNotFoundException) {
                    var rawOffset = doc.Descendants(@"raw_offset").FirstOrDefault()?.Value;
                    var zoneName = doc.Descendants(@"time_zone_name").FirstOrDefault()?.Value;
                    if (rawOffset == null || zoneName == null) throw new Exception("Invalid response");
                    return TimeZoneInfo.CreateCustomTimeZone(zoneId, TimeSpan.FromSeconds(FlexibleParser.ParseDouble(rawOffset)), zoneName, zoneName);
                }
            }
        }
    }
GoogleApiProvider