Method: TimeCalc::Diff#modulo

Defined in:
lib/time_calc/diff.rb

#modulo(span, unit) ⇒ Time, Date or DateTime #modulo(unit) ⇒ Time, Date or DateTime Also known as: %

Same as integer modulo: the “rest” of whole division of the distance between two time points by ‘<span> <units>`. This rest will be also time point, equal to `first diff operand - span units`

Overloads:

  • #modulo(span, unit) ⇒ Time, Date or DateTime

    Parameters:

    • span (Integer)
    • unit (Symbol)

      Any of supported units (see TimeCalc)

  • #modulo(unit) ⇒ Time, Date or DateTime

    Shortcut for ‘modulo(1, unit)`.

    Parameters:

    • unit (Symbol)

      Any of supported units (see TimeCalc)

Returns:

  • (Time, Date or DateTime)

    Value is always the same type as first diff operand



132
133
134
# File 'lib/time_calc/diff.rb', line 132

def modulo(span, unit = nil)
  divmod(span, unit).last
end