Skip to content

🕙 Use unix epoch to generate ticks#189

Merged
rkorsak merged 2 commits intomainfrom
bug/fix-ticks
Sep 28, 2020
Merged

🕙 Use unix epoch to generate ticks#189
rkorsak merged 2 commits intomainfrom
bug/fix-ticks

Conversation

@rkorsak
Copy link
Copy Markdown
Contributor

@rkorsak rkorsak commented Sep 28, 2020

Fixes #190

Description

  • Updates the utils.to_ticks function to use the unix epoch (seconds since January 1, 1970 UTC)
  • Replaces the use of datetime.utcnow with datetime.now, as utcnow is considered harmful and ironically produces the wrong epoch timestamp.

Note: sample data will need to be regenerated, but we have several other hashing/format changes coming and should address that in one sweep.

Testing

Unit tests for utils.to_ticks have been augmented to cover more flavors of datetime.

Checklist

🚨Please review the guidelines for contributing to this repository.

  • 🤔 CONSIDER adding a unit test if your PR resolves an issue.
  • DO check open PR's to avoid duplicates.
  • DO keep pull requests small so they can be easily reviewed.
  • DO build locally before pushing.
  • DO make sure tests pass.
  • DO make sure any new changes are documented.
  • DO make sure not to introduce any compiler warnings.
  • AVOID breaking the continuous integration build.
  • AVOID making significant changes to the overall architecture.

💚 Thank you!

@rkorsak rkorsak marked this pull request as ready for review September 28, 2020 19:14
keithrfung
keithrfung previously approved these changes Sep 28, 2020
Copy link
Copy Markdown
Contributor

@keithrfung keithrfung left a comment

Choose a reason for hiding this comment

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

looks good to me.

Wouldn't mind second review here @AddressXception

"""
Return the number of ticks for a date time
Return the number of ticks for a date time.
Ticks are defined here as number of seconds since the unix epoch (00:00:00 UTC on 1 January 1970)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Appreciate the verbage here.

Comment thread src/electionguard/utils.py Outdated
@rkorsak rkorsak merged commit 35a76a4 into main Sep 28, 2020
@rkorsak rkorsak deleted the bug/fix-ticks branch September 28, 2020 20:28
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 this pull request may close these issues.

🐛 Datetime tick generation is inconsistent

2 participants