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

MongoDB: Fix timestamp conversion #58

Closed
wants to merge 1 commit into from

Conversation

amotl
Copy link
Member

@amotl amotl commented Sep 24, 2024

About

Swap instruction to encode datetime values to unix time.

# Previous
calendar.timegm(datetime.utctimetuple())

# Now
datetime.timestamp()

Originally, the previous code is coming from the implementation of migr8, specifically its date_converter, see migr8/export.py#L52, added by @autophagy with crate/mongodb-cratedb-migration-tool@544c4974cf8.

Thoughts

While reviewing the code base, I may have discovered a minor flaw with timestamp conversions. On the other hand, I might also be wrong on this. What do you think about it?

Base automatically changed from refinements-1 to main September 25, 2024 00:04
@amotl amotl force-pushed the collab/mongodb-fix-timestamp-conversion branch from c13b2f0 to c33fdc9 Compare September 25, 2024 00:05
@amotl amotl requested review from seut and matriv September 25, 2024 00:14
Copy link
Member Author

@amotl amotl left a comment

Choose a reason for hiding this comment

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

I think the current variant is correct. Closing this.

Comment on lines -166 to +165
return calendar.timegm(datetime.utctimetuple())
return datetime.timestamp()
Copy link
Member Author

Choose a reason for hiding this comment

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

The previous instruction behaves better in all situations, as it produces the same results even when invoked on systems running different time zones.

@amotl amotl closed this Sep 25, 2024
@amotl amotl deleted the collab/mongodb-fix-timestamp-conversion branch September 25, 2024 00:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant