in services/date.py [0:0]
def to_unix_timestamp(date_str: str) -> int:
"""
Convert a date string to a unix timestamp (seconds since epoch).
Args:
date_str: The date string to convert.
Returns:
The unix timestamp corresponding to the date string.
If the date string cannot be parsed as a valid date format, returns the current unix timestamp and prints a warning.
"""
# Try to parse the date string using arrow, which supports many common date formats
try:
date_obj = arrow.get(date_str)
return int(date_obj.timestamp())
except arrow.parser.ParserError:
# If the parsing fails, return the current unix timestamp and print a warning
logger.info(f"Invalid date format: {date_str}")
return int(arrow.now().timestamp())