Example #1
0
def timezone(location):
    '''
    Get the timezone for a location.
    '''

    try:
        return l_timezone(location)
    except UnknownTimeZoneError:
        pass

    timestamp = time()
    coordinates = geocode(location)

    return l_timezone(request(
        "timezone",
        location="{lat},{lng}".format(**coordinates),
        timestamp=timestamp
    )['timeZoneId'])
Example #2
0
    def test_direct_timezone(self):
        '''
        Check if directly passing timezones works.
        '''

        self.assertEqual(timezone('Asia/Calcutta'), l_timezone('Asia/Calcutta'))