Posix Time (original) (raw)

boost::int64_t hours()

Get the number of normalized hours (will give unpredictable results if calling time_duration is a special_value).

time_duration td(1,2,3); time_duration neg_td(-1,2,3); td.hours(); // --> 1 neg_td.hours(); // --> -1

boost::int64_t minutes()

Get the number of minutes normalized +/-(0..59) (will give unpredictable results if calling time_duration is a special_value).

time_duration td(1,2,3); time_duration neg_td(-1,2,3); td.minutes(); // --> 2 neg_td.minutes(); // --> -2

boost::int64_t seconds() const

Get the normalized number of second +/-(0..59) (will give unpredictable results if calling time_duration is a special_value).

time_duration td(1,2,3); time_duration neg_td(-1,2,3); td.seconds(); // --> 3 neg_td.seconds(); // --> -3

boost::int64_t total_seconds() const

Get the total number of seconds truncating any fractional seconds (will give unpredictable results if calling time_duration is a special_value).

time_duration td(1,2,3,10); td.total_seconds(); // --> (13600) + (260) + 3 == 3723

boost::int64_t total_milliseconds() const

Get the total number of milliseconds truncating any remaining digits (will give unpredictable results if calling time_duration is a special_value).

time_duration td(1,2,3,123456789); td.total_milliseconds(); // HMS --> (13600) + (260) + 3 == 3723 seconds // milliseconds is 3 decimal places // (3723 * 1000) + 123 == 3723123

boost::int64_t total_microseconds() const

Get the total number of microseconds truncating any remaining digits (will give unpredictable results if calling time_duration is a special_value).

time_duration td(1,2,3,123456789); td.total_microseconds(); // HMS --> (13600) + (260) + 3 == 3723 seconds // microseconds is 6 decimal places // (3723 * 1000000) + 123456 == 3723123456

boost::int64_t total_nanoseconds() const

Get the total number of nanoseconds truncating any remaining digits (will give unpredictable results if calling time_duration is a special_value).

time_duration td(1,2,3,123456789); td.total_nanoseconds(); // HMS --> (13600) + (260) + 3 == 3723 seconds // nanoseconds is 9 decimal places // (3723 * 1000000000) + 123456789 // == 3723123456789

boost::int64_t fractional_seconds() const

Get the number of fractional seconds (will give unpredictable results if calling time_duration is a special_value).

time_duration td(1,2,3, 1000); td.fractional_seconds(); // --> 1000

bool is_negative() const

True if and only if duration is negative.

time_duration td(-1,0,0); td.is_negative(); // --> true

bool is_zero() const

True if and only if duration is zero.

time_duration td(0,0,0); td.is_zero(); // --> true

bool is_positive() const

True if and only if duration is positive.

time_duration td(1,0,0); td.is_positive(); // --> true

time_duration invert_sign() const

Generate a new duration with the sign inverted.

time_duration td(-1,0,0); td.invert_sign(); // --> 01:00:00

time_duration abs() const

Generate a new duration with the absolute value of the time duration.

time_duration td(-1,0,0); td.abs(); // --> 01:00:00

time_duration td(+1,0,0); td.abs(); // --> 01:00:00

date_time::time_resolutions time_duration::resolution()

Describes the resolution capability of the time_duration class. time_resolutions is an enum of resolution possibilities ranging from seconds to nanoseconds.

time_duration::resolution() --> nano

unsigned short time_duration::num_fractional_digits()

Returns the number of fractional digits the time resolution has.

unsigned short secs; secs = time_duration::num_fractional_digits(); // 9 for nano, 6 for micro, etc.

boost::int64_t time_duration::ticks_per_second()

Return the number of ticks in a second. For example, if the duration supports nanoseconds then the returned result will be 1,000,000,000 (1e+9).

std::cout << time_duration::ticks_per_second();

boost::int64_t ticks()

Return the raw count of the duration type (will give unpredictable results if calling time_duration is a special_value).

time_duration td(0,0,0, 1000); td.ticks() // --> 1000

time_duration time_duration::unit()

Return smallest possible unit of duration type (1 nanosecond).

time_duration::unit() --> time_duration(0,0,0,1)

bool is_neg_infinity() const

Returns true if time_duration is negative infinity

time_duration td(neg_infin); td.is_neg_infinity(); // --> true

bool is_pos_infinity() const

Returns true if time_duration is positive infinity

time_duration td(pos_infin); td.is_pos_infinity(); // --> true

bool is_not_a_date_time() const

Returns true if value is not a time

time_duration td(not_a_date_time); td.is_not_a_date_time(); // --> true

bool is_special() const

Returns true if time_duration is any special_value

time_duration td(pos_infin); time_duration td2(not_a_date_time); time_duration td3(2,5,10); td.is_special(); // --> true td2.is_special(); // --> true td3.is_special(); // --> false