Construct a time value from a Duration.
Construct a time value from a number of microseconds.
Construct a time value from a number of milliseconds.
Construct a time value from a number of seconds.
Represents a time value.
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));
$(CLOCK_LINK)
$(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.