Closed tisonkun closed 5 months ago
Does RELATIVE_BASE
work?
@Gallaecio Sounds like I should calculate the start of today and use it for this setting?
@Gallaecio Thank you! I got something like this works:
start_of_today = datetime.combine(datetime.now(UTC), time(0, 0, 0, 0, UTC))
date_since = dateparser.parse(
os.getenv('DATE_SINCE') or '2 weeks ago',
settings={
'RETURN_AS_TIMEZONE_AWARE': True,
'RELATIVE_BASE': start_of_today,
})
date_until = dateparser.parse(
os.getenv('DATE_UNTIL') or 'now',
settings={
'RETURN_AS_TIMEZONE_AWARE': True,
'RELATIVE_BASE': start_of_today,
})
print(f"Date since: {date_since}")
print(f"Date until: {date_until}")
Currently,
two weeks ago
goes back to two weeks ago at the current moment. But I may prefer to align with 0:00.Is it possible to achieve?