Skip to content
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

sopel: using utcnow and fixing minor issues with datetime #2005

Merged
merged 4 commits into from
Jan 24, 2021

Conversation

Exirel
Copy link
Contributor

@Exirel Exirel commented Dec 19, 2020

Description

This is related to #1647. It doesn't fix it but we may consider it done nonetheless.

What I looked at was how we use datetime internally and in various plugins, to check if everything was working fine. Result is: no, but it's OK, I fixed it with this PR.

The biggest issue I found was a repeated usage of timedelta.seconds that I replaced by timedelta.total_seconds().

Checklist

  • I have read CONTRIBUTING.md
  • I can and do license this contribution under the EFLv2
  • No issues are reported by make qa (runs make quality and make test)
  • I have tested the functionality of the things this change touches

@Exirel Exirel added Tweak Bugfix Generally, PRs that reference (and fix) one or more issue(s) labels Dec 19, 2020
@Exirel Exirel added this to the 7.1.0 milestone Dec 19, 2020
@Exirel Exirel requested a review from dgw December 19, 2020 14:11
Copy link
Member

@dgw dgw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More little ideas on a 99%-there PR.

sopel/trigger.py Outdated Show resolved Hide resolved
sopel/trigger.py Outdated Show resolved Hide resolved
@Exirel Exirel requested a review from dgw December 26, 2020 18:16
Copy link
Member

@dgw dgw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉 and ready to squash (as is PR 2006, even though I forgot to say so)

Exirel and others added 4 commits December 29, 2020 17:04
Three important changes in one commit:

The first was to switch from `datetime`'s `now()` to `utcnow()`,
because DST exists and we need to take that into account.

The second one is to switch from `timedelta`'s `seconds` to
`total_seconds()`, because, believe it or not, but a timedelta of
exactly one day means `dt.seconds == 0`.

The last one is a fix for a TODO that has been bugging me since I read
it. Now, when there is a "fatal" error, we decrease the error count
by one per every full 5s that passed since the last error.

Maybe we should do that every time, but I figured it would be an
acceptable tradeoff for now.
Co-authored-by: dgw <dgw@technobabbl.es>
@Exirel Exirel force-pushed the internal-datetime-utc branch from 44bcaf0 to cc3d5d1 Compare December 29, 2020 16:04
@Exirel
Copy link
Contributor Author

Exirel commented Dec 29, 2020

And done.

@dgw dgw merged commit 39f4f1a into sopel-irc:master Jan 24, 2021
@Exirel Exirel deleted the internal-datetime-utc branch May 1, 2021 17:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bugfix Generally, PRs that reference (and fix) one or more issue(s) Tweak
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants