Skip to content

Datetime in next_cron func doesn't have timezone information #380

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

Closed
TyrPhoonn opened this issue Dec 16, 2022 · 3 comments · Fixed by #383
Closed

Datetime in next_cron func doesn't have timezone information #380

TyrPhoonn opened this issue Dec 16, 2022 · 3 comments · Fixed by #383

Comments

@TyrPhoonn
Copy link

TyrPhoonn commented Dec 16, 2022

I have one issue at line 47 in cron.py return next_datetime values without timezone information.
I think it will be happen when your frequency_time greater than now and next_cron will move to next year.
You can try with current time and next_cron is any day of next year.

You can use this code to replace while loop at line 43

while True:
    next_dt = _get_next_dt(dt, options)
    if next_dt is None:
        return dt.replace(tzinfo=datetime.now().astimezone().tzinfo)
    dt = next_dt
@JonasKs
Copy link
Collaborator

JonasKs commented Dec 18, 2022

Maybe @iamlikeme who built tz aware cron jobs has any insight here? 😊 I won't be able to look into this for a while.

@JonasKs
Copy link
Collaborator

JonasKs commented Dec 18, 2022

PRs with tests always welcome 🙏

@iamlikeme
Copy link
Contributor

Thanks @TyrPhoonn for reporting the bug, and thanks @JonasKs for pinging me 👍 I submitted a PR with a bugfix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants