<commit_before>﻿using System;
using System.Threading.Tasks;
using Mobilize.Common.Http;
using Mobilize.Location.Entities;
using NodaTime;

namespace Mobilize.Location.Helpers
{
    public class GoogleTimeZoneApiHelper
    {
        private const string GoogleTimeZoneApiUrlFormat = "https://maps.googleapis.com/maps/api/timezone/json?location={0},{1}&timestamp={2}&key={3}";

        public async static Task<DateTimeZone> GetDateTimeZone(string apiKey, double latitude, double longitude)
        {
            try
            {
                long timestamp = GetTimestamp();
                string url = string.Format(GoogleTimeZoneApiUrlFormat, latitude, longitude, timestamp, apiKey);
                var response = await RestClient.GetAsync<GoogleTimeZoneApiResponse>(url);
                return DateTimeZoneProviders.Tzdb.GetZoneOrNull(response.TimeZoneId);
            }
            catch
            {
                return null;
            }
        }

        private static long GetTimestamp()
        {
            return (long)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds;<commit_msg>new method to return timezone id<commit_after>﻿using System;
using System.Threading.Tasks;
using Mobilize.Common.Http;
using Mobilize.Location.Entities;
using NodaTime;

namespace Mobilize.Location.Helpers
{
    public class GoogleTimeZoneApiHelper
    {
        private const string GoogleTimeZoneApiUrlFormat = "https://maps.googleapis.com/maps/api/timezone/json?location={0},{1}&timestamp={2}&key={3}";

        public async static Task<DateTimeZone> GetDateTimeZone(string apiKey, double latitude, double longitude)
        {
            var timeZoneId = await GetDateTimeZoneId(apiKey, latitude, longitude);
            return DateTimeZoneProviders.Tzdb.GetZoneOrNull(timeZoneId);
        }

        public async static Task<string> GetDateTimeZoneId(string apiKey, double latitude, double longitude)
        {
            try
            {
                long timestamp = GetTimestamp();
                string url = string.Format(GoogleTimeZoneApiUrlFormat, latitude, longitude, timestamp, apiKey);
                var response = await RestClient.GetAsync<GoogleTimeZoneApiResponse>(url);
                return response.TimeZoneId;
            }
            catch
            {
                return null;
            }
        }

        private static long GetTimestamp()
        {
            return (long)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds;
{'fraction_non_alphanumeric': 0.08815317112086159, 'fraction_numerical': 0.007977662544874352, 'mean_word_length': 2.5224719101123596, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 8, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2008183', 'n_tokens_mistral': 669, 'n_tokens_neox': 632, 'n_words': 140}