示例#1
0
文件: location.py 项目: crodjer/atg
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'])
示例#2
0
    def test_direct_timezone(self):
        '''
        Check if directly passing timezones works.
        '''

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