#std.time.Instant - how to use

1 messages · Page 1 of 1 (latest)

coarse bison
#

Hey,

I have a struct where I want to store the timestamp of the last activity.

I’m a bit confused about how to deal with that.

Should I/How:

  • keep std.time.Instant in my struct and operate on it, or
  • unpack it into something like isize and keep isize?
  • how should I subtract X seconds from the current time? there is isize ns ans isize of seconds under timestamp, should i recreate Instance manualy after substracion?
  • Why isn’t there a separate TimeDelta / Duration struct for this?
  • why i dont have a single isize

What’s the recommended approach?

THX!

#

std.time.Instant - how to use

nimble badger
#

If you're on master, you might be interested in looking at std.Io.Clock, std.Io.Timestamp, and std.Io.Duration

coarse bison
#

but why it is under Io?

#

yes i am

nimble badger
#

Doing time stuff needs io, I guess

#

Everything was probably moved to keep it close together, rather than having some stuff in std.Io and some in std.time

coarse bison
#

ok, i will investigate it. So std.time will be removed or what?

nimble badger
#

Probably

coarse bison
#

I already used Timer (monotonic) from there

#

it do not invloves io's for sure

#

i would be suprised if they move it

nimble badger