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

Allows to convert into/from micros_since_epoch:u64 for TimeStamp #731

Merged
merged 1 commit into from
Jan 18, 2024

Conversation

mamcx
Copy link
Contributor

@mamcx mamcx commented Jan 18, 2024

Description of Changes

To make it possible to integrate spacetimedb::Timestamp with chrono, I add a way to convert into/from micros_since_epoch:u64

Expected complexity level and risk

1

Copy link
Collaborator

@joshua-spacetime joshua-spacetime left a comment

Choose a reason for hiding this comment

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

Any reason not to prefer From<Timestamp> for u64?

@mamcx
Copy link
Contributor Author

mamcx commented Jan 18, 2024

Any reason not to prefer From<Timestamp> for u64?

Mainly for the semantics (so is clear wich unit is used here)

@mamcx mamcx added this pull request to the merge queue Jan 18, 2024
Merged via the queue into master with commit ffd22de Jan 18, 2024
5 checks passed
@gefjon
Copy link
Contributor

gefjon commented Jan 18, 2024

Any reason not to prefer From<Timestamp> for u64?

Agreed w/ Mario; Timestamp::from(n) could do any number of different things, e.g. treat as seconds, millis, micros or nanos, and doesn't necessarily refer to an offset from the UNIX epoch (e.g. Rust's std::time::Instant is not), but Timestamp::from_micros_since_epoch says exactly what it does.

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.

3 participants