text = "Going out with Sahi to Ikebukuro next week around 4PM or 16:30"
dt_now = datetime.datetime.now()
print('Date and time now:', dt_now.strftime('%Y/%m/%d %H:%M:%S'))
text = re.sub(r'(today)', f'{dt_now.month}/{dt_now.day}', text)
text = re.sub(r'(tomorrow)', f'{dt_now.month}/{dt_now.day + 1}', text)
text = re.sub(r'(the day after tomorrow)', f'{dt_now.month}/{dt_now.day + 2}', text)
text = re.sub(r'(in 2 days)', f'{dt_now.month}/{dt_now.day + 2}', text)
text = re.sub(r'(in 3 days)', f'{dt_now.month}/{dt_now.day + 3}', text)
text = re.sub(r'(yesterday)', f'{dt_now.month}/{dt_now.day - 1}', text)
text = re.sub(r'(next week)', f'{dt_now.month}/{dt_now.day + 7}', text)
text = re.sub(r'(in a month)', f'{dt_now.month + 1}/{dt_now.day}', text)
print(text)
In the code above, I have tried to convert any date-like words directly to absolute dates and hence hard-coded the solution. However, is there a way that I can soft-code it.