Module: OpenHAB::DSL::MonkeyPatch::JavaExtensions::TimeExtensions

Included in:
LocalTimeExtensions, ZonedDateTimeExtensions
Defined in:
lib/openhab/dsl/monkey_patch/java/time_extensions.rb

Overview

Common extensions to Java date/time classes

Instance Method Summary collapse

Instance Method Details

#+(other) ⇒ ZonedDateTime

Add other TemporalAmount or Duration object

Parameters:

  • other (TemporalAmount)

    the TemporalAmount to be added to this ZonedDateTime object

Returns:

  • (ZonedDateTime)

    The resulting ZonedDateTime object after adding other



18
19
20
# File 'lib/openhab/dsl/monkey_patch/java/time_extensions.rb', line 18

def +(other)
  plus(other)
end

#-(other) ⇒ ZonedDateTime

Subtract other TemporalAmount or Duration object

Parameters:

  • other (TemporalAmount)

    the TemporalAmount to be subtracted from this ZonedDateTime object

Returns:

  • (ZonedDateTime)

    The resulting ZonedDateTime object after subtracting other



29
30
31
# File 'lib/openhab/dsl/monkey_patch/java/time_extensions.rb', line 29

def -(other)
  minus(other)
end

#<=>(other) ⇒ Integer

Compare against another time object

Parameters:

  • other (Object)

    The other time object to compare against.

Returns:

  • (Integer)

    -1, 0, +1 depending on whether other is less than, equal to, or greater than self



41
42
43
44
45
# File 'lib/openhab/dsl/monkey_patch/java/time_extensions.rb', line 41

def <=>(other)
  compare_to(other)
rescue StandardError
  nil
end