-
-
Notifications
You must be signed in to change notification settings - Fork 230
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Does enqueue_at support timezones ? #101
Comments
If you look at the documentation, you see mentions of UTC time all over, but in particular: So the answer is, use UTC. |
Maybe it'd be a nice feature for Rq-scheduler to care about the timezone and localize the time scheduled |
The reason why we don't handle timezones is because we need to depend on external packages such as I think it should be we should be able to convert timezone aware datetimes into UTC but I don't have the time to look too deeply about this. If you know how to do this, PR is welcome :) |
Since 0.6.0 rq-scheduler user croniter, which use dateutil, so setting timezone can be done like this: from datetime import datetime
from dateutil.tz import gettz
tz = "US/Pacific"
datetime(2020, 1, 1 tzinfo=gettz(tz)).astimezone(gettz("UTC"))
# datetime.datetime(2020, 1, 1, 8, 0, tzinfo=tzwin('UTC')) For example, to support timezones in cron jobs, default from datetime import datetime
from dateutil.tz import gettz
def get_next_scheduled_time_with_tz(cron_string, tz=None):
tz = "UTC" if tz else tz
itr = croniter.croniter(cron_string, datetime.now(gettz(tz)))
return itr.get_next(datetime).astimezone(gettz("UTC")) And |
+1 for this, please 👍 |
I want to enqueue a job at California timezone.
Will it work or will it ignore the timezone and execute at django's defined timezone ?
Thanks
The text was updated successfully, but these errors were encountered: