Exemplo n.º 1
0
/// Calculates the delta between two timestamps.
///
/// \param other The subtrahend.
///
/// \return The difference between this object and the other object.
///
/// \throw std::runtime_error If the subtraction would result in a negative time
///     delta, which are currently not supported.
datetime::delta
datetime::timestamp::operator-(const datetime::timestamp& other) const
{
    if ((*this) < other) {
        throw std::runtime_error(
            F("Cannot subtract %s from %s as it would result in a negative "
              "datetime::delta, which are not supported") % other % (*this));
    }
    return datetime::delta::from_microseconds(to_microseconds() -
                                              other.to_microseconds());
}
Exemplo n.º 2
0
/// Calculates the delta between two timestamps.
///
/// \param other The subtrahend.
///
/// \return The difference between this object and the other object.
datetime::delta
datetime::timestamp::operator-(const datetime::timestamp& other) const
{
    return datetime::delta::from_microseconds(to_microseconds() -
                                              other.to_microseconds());
}
Exemplo n.º 3
0
/// Binds a timestamp to a statement parameter.
///
/// \param stmt The statement to which to bind the parameter.
/// \param field The name of the parameter; must exist.
/// \param timestamp The value to bind.
void
store::bind_timestamp(sqlite::statement& stmt, const char* field,
                      const datetime::timestamp& timestamp)
{
    stmt.bind(field, timestamp.to_microseconds());
}
Exemplo n.º 4
0
/// Checks if a timestamp is after or equal to another.
///
/// \param other The object to compare to.
///
/// \return True if this timestamp comes after other or is equal to it;
/// false otherwise.
bool
datetime::timestamp::operator>=(const datetime::timestamp& other) const
{
    return to_microseconds() >= other.to_microseconds();
}