Пример #1
0
/// Binds a time delta to a statement parameter.
///
/// \param stmt The statement to which to bind the parameter.
/// \param field The name of the parameter; must exist.
/// \param delta The value to bind.
void
store::bind_delta(sqlite::statement& stmt, const char* field,
                  const datetime::delta& delta)
{
    stmt.bind(field, static_cast< int64_t >(delta.to_microseconds()));
}
Пример #2
0
/// Adds a time delta to this one.
///
/// \param other The time delta to add.
///
/// \return The addition of this time delta with the other time delta.
datetime::delta
datetime::delta::operator+(const datetime::delta& other) const
{
    return delta::from_microseconds(to_microseconds() +
                                    other.to_microseconds());
}
Пример #3
0
/// Calculates the subtraction of a delta from a timestamp.
///
/// \param other The delta to subtract.
///
/// \return A new timestamp in the past.
datetime::timestamp
datetime::timestamp::operator-(const datetime::delta& other) const
{
    return datetime::timestamp::from_microseconds(to_microseconds() -
                                                  other.to_microseconds());
}