Skip to content

boost::posix_time::duration multiplication/division limited to int. #246

@JohannesWilde

Description

@JohannesWilde

The operator*(), operator*=(), operator/(), and operator/=() currently only support int parameters [see boost::posix_time::duration].

I tried to use it as follows:

std::uint64_t const timedeltaInTensOfNanoseconds = 2793555578;
boost::posix_time::time_duration const duration = boost::posix_time::nanoseconds(10) * timestamp;
// duration.total_nanoseconds() = -15014117180

[I did define BOOST_DATE_TIME_POSIX_TIME_STD_CONFIG.]

What did work as expected was:

std::uint64_t const timedeltaInTensOfNanoseconds = 2793555578;
boost::posix_time::time_duration const duration = boost::posix_time::nanoseconds(10 * timestamp);
// duration.total_nanoseconds() = 27935555780

Would it be possible to extend the parameter type for above functions to at least support unsigned as well? Or even extend it to 64-bit types? Or make them template-methods [with a concept limiting them to ints and floats]?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions