0

I want to convert a time_point variable to a string using eos studio. I need to insert a time_point variable in a string in order to creare the object of my smart contract.

1

1 Answer 1

0

below is my code:

struct TimePoint_micro_sec {
    int64_t count;

    [[nodiscard]] std::string  ToString() const;
};

std::string TimePoint_micro_sec::ToString() const {
    const uint64_t    seconds      = count / 1'000'000ULL;
    const uint64_t    milliseconds = (count % 1'000'000ULL) / 1'000ULL;
    const std::string padded_ms    = std::to_string(milliseconds + 1'000ULL).substr(1);
    const auto        ptime        = boost::posix_time::from_time_t(time_t(seconds));
    return boost::posix_time::to_iso_extended_string(ptime) + "." + padded_ms;
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.