Skip to content

@tasks.loop(time=x) not working for me #9547

Answered by Rapptz
Nalanii asked this question in Q&A
Discussion options

You must be logged in to vote

This is an issue with timezones. Naive times for the task extension are interpreted as UTC time, datetime.datetime.now() is a naive datetime representing local time. In order to make your datetime proper you need to make it an aware time for your local timezone. Using astimezone() is enough for that. e.g.

local_tz = datetime.datetime.now().astimezone().tzinfo
goodNightTime = datetime.time(hour=19, minute=46, tzinfo=local_tz)

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@Nalanii
Comment options

Answer selected by Nalanii
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants