nudsfml.system.time

$(U Time) encapsulates a time value in a flexible way. It allows to define a time value either as a number of seconds, milliseconds or microseconds. It also works the other way round: you can read a time value as either a number of seconds, milliseconds or microseconds.

By using such a flexible interface, the API doesn't impose any fixed type or resolution for time values, and let the user choose its own favorite representation.

Time values support the usual mathematical operations: you can add or subtract two times, multiply or divide a time by a number, compare two times, etc.

Since they represent a time span and not an absolute time value, times can also be negative.

Members

Functions

duration
Time duration(Duration dur)

Construct a time value from a Duration.

microseconds
Time microseconds(long amount)

Construct a time value from a number of microseconds.

milliseconds
Time milliseconds(int amount)

Construct a time value from a number of milliseconds.

seconds
Time seconds(float amount)

Construct a time value from a number of seconds.

Imports

Duration (from core.time)
public import core.time : Duration;
Undocumented in source.

Structs

Time
struct Time

Represents a time value.

Examples

Time t1 = seconds(0.1f);
Int milli = t1.asMilliseconds(); // 100

Time t2 = sf::milliseconds(30);
long micro = t2.asMicroseconds(); // 30000

Time t3 = sf::microseconds(-800000);
float sec = t3.asSeconds(); // -0.8
void update(Time elapsed)
{
   position += speed * elapsed.asSeconds();
}

update(milliseconds(100));

See Also

$(CLOCK_LINK)

Meta