View source code
Display the source code in core/time.d from which this page was generated on github.
Report a bug
If you spot a problem with this page, click here to create a Bugzilla issue.
Improve this page
Quickly fork, edit online, and submit a pull request for this page. Requires a signed-in GitHub account. This works well for small changes. If you'd like to make larger changes you may want to consider using local clone.

Function core.time.to

Converts a TickDuration to the given units as either an integral value or a floating point value.

T to(string units, T, D) (
  D td
) pure nothrow @nogc @safe
if (is(immutable(D) == immutable(TickDuration)) && (units == "seconds" || units == "msecs" || units == "usecs" || units == "hnsecs" || units == "nsecs"));

Parameters

NameDescription
units The units to convert to. Accepts "seconds" and smaller only.
T The type to convert to (either an integral type or a floating point type).
td The TickDuration to convert

Example

auto t = TickDuration.from!"seconds"(1000);

long tl = to!("seconds",long)(t);
writeln(tl); // 1000

import core.stdc.math : fabs;
double td = to!("seconds",double)(t);
assert(fabs(td - 1000) < 0.001);

Authors

Jonathan M Davis and Kato Shoichi

License

Boost License 1.0.