iroha icon indicating copy to clipboard operation
iroha copied to clipboard

refactor: Use `SystemTime` for timestamps

Open dima74 opened this issue 1 year ago • 3 comments

Context

Fixes #4729

Solution

Use std::time::SystemTime for time stamps instead of std::time::Duration.

  • Note that SystemTime requires std, so it will not be available inside WASM.
  • Alternatively chrono::DateTime might be used, but it will be more complex (in particular we will have to handle leap seconds), so I am not sure that it is worth it

Migration Guide (optional)

Review notes (optional)

Checklist

  • [ ] I've read CONTRIBUTING.md.
  • [ ] (optional) I've written unit tests for the code changes.
  • [ ] All review comments have been resolved.

dima74 avatar Aug 27 '24 12:08 dima74

From SDK standpoint, it can be useful to clearly see the separation between durations and timestamps in the schema. Currently they are just *_ms: u64 fields.

0x009922 avatar Sep 02 '24 02:09 0x009922

From SDK standpoint, it can be useful to clearly see the separation between durations and timestamps in the schema. Currently they are just *_ms: u64 fields.

One option I see here is to create DurationMs and TimestampMs newtype wrappers for u64 and use them correspondingly

dima74 avatar Sep 02 '24 15:09 dima74

One option I see here is to create DurationMs and TimestampMs newtype wrappers for u64 and use them correspondingly

That would be helpful.

0x009922 avatar Sep 09 '24 08:09 0x009922

Closed, treating the latter option in https://github.com/hyperledger-iroha/iroha/pull/5015#discussion_r1812936037 as our conclusion.

s8sato avatar Jul 08 '25 22:07 s8sato