On Tuesday, December 05, 2017 21:33:53 Joel via Digitalmars-d-learn wrote:
> void main() {
>   import std.datetime: Duration, msecs;
>   import std.datetime.stopwatch: StopWatch;
>
>   StopWatch sw;
>   if (sw.peek.msecs) {
>
>   }
> }
>
> I get this error with the code:
> z.d(6): Error: function core.time.dur!"msecs".dur (long length)
> is not callable using argument types (Duration)

core.time.msecs is an alias for core.time.dur!"msecs". It takes a long for
the number of milliseconds and returns a Duration. If you want to convert a
Duration to milliseconds, then use its member function, total. e.g.
sw.peek.total!"msecs". It will convert the hnsecs in the duration to msecs
using integral math and return a long.

If what you want is a floating point value like TickDuration.msecs does,
then you'll have to do the math yourself with something like
sw.peek.total!"hnsecs" / cast(real)convert!("seconds", "hnsecs")(1).

https://dlang.org/phobos/core_time.html#.msecs
https://dlang.org/phobos/core_time.html#.Duration.total

- Jonathan M Davis

Reply via email to