Spaces:
Runtime error
Runtime error
| from dateparser import parse | |
| from geopy import Nominatim | |
| goe_location = Nominatim(user_agent="geoapi") | |
| def get_location(address: str): | |
| """ | |
| Gets the geographical location of an address using Nominatim. | |
| Args: | |
| address (str): The address to geocode. | |
| Returns: | |
| tuple: A tuple containing latitude and longitude of the address. | |
| """ | |
| location = goe_location.geocode(address) | |
| if location: | |
| return { | |
| 'name': address, | |
| 'address': location.address, | |
| 'latitude': location.latitude, | |
| 'longitude': location.longitude, | |
| } | |
| else: | |
| raise address | |
| def parse_date(date_str): | |
| """ | |
| Parses a date string into a datetime object. | |
| Args: | |
| date_str (str): The date string to parse. | |
| Returns: | |
| datetime.datetime: The parsed date as a datetime object. | |
| """ | |
| return parse(date_str) | |
| if __name__ == "__main__": | |
| # Example usage | |
| date_str = "2025-9-10" | |
| loc = "Phnom Pen" | |
| parsed_date = parse_date(date_str) | |
| print(f"Parsed date: {parsed_date}") | |
| print(f"Location of {loc}: {get_location(loc)}") |