Correcting the retrieval of relevant documents
This commit is contained in:
19
common/utils/datetime_utils.py
Normal file
19
common/utils/datetime_utils.py
Normal file
@@ -0,0 +1,19 @@
|
||||
from datetime import datetime
|
||||
import pytz
|
||||
|
||||
|
||||
def get_date_in_timezone(timezone_str):
|
||||
try:
|
||||
# Get the timezone object from the string
|
||||
timezone = pytz.timezone(timezone_str)
|
||||
|
||||
# Get the current time in the specified timezone
|
||||
current_time = datetime.now(timezone)
|
||||
|
||||
# Extract the date part
|
||||
current_date = current_time.date()
|
||||
|
||||
return current_date
|
||||
except Exception as e:
|
||||
print(f"Error getting date in timezone {timezone_str}: {e}")
|
||||
return None
|
||||
Reference in New Issue
Block a user