Class: OpenHAB::CoreExt::Java::Month

Inherits:
Object
  • Object
show all
Includes:
Between, Time, TimePredicates
Defined in:
lib/openhab/core_ext/java/month.rb

Overview

Extensions to java.time.Month

Instance Method Summary collapse

Methods included from Time

#<=>, #coerce

Methods included from Between

#between?

Methods included from TimePredicates

#within?

Instance Method Details

#+(other) ⇒ Month

Returns:



18
19
20
# File 'lib/openhab/core_ext/java/month.rb', line 18

def +(other)
  plus(other)
end

#-(other) ⇒ Month

Returns:



23
24
25
# File 'lib/openhab/core_ext/java/month.rb', line 23

def -(other)
  minus(other)
end

#succMonth

Returns the next month

Will loop back to January if necessary.

Returns:



34
35
36
# File 'lib/openhab/core_ext/java/month.rb', line 34

def succ
  plus(1)
end

#to_date(context = nil) ⇒ Date

Returns:



46
47
48
# File 'lib/openhab/core_ext/java/month.rb', line 46

def to_date(context = nil)
  to_local_date(context).to_date
end

#to_instant(context = nil) ⇒ Instant

Parameters:

  • context (ZonedDateTime, nil) (defaults to: nil)

    A ZonedDateTime used to fill in the year during conversion, with the date set to the first day of the month. Instant.now is assumed if not given.

Returns:



73
74
75
76
# File 'lib/openhab/core_ext/java/month.rb', line 73

def to_instant(context = nil)
  context ||= Instant.now.to_zoned_date_time
  to_local_date(context).to_instant
end

#to_local_date(context = nil) ⇒ LocalDate

Returns:



39
40
41
42
43
# File 'lib/openhab/core_ext/java/month.rb', line 39

def to_local_date(context = nil)
  context ||= java.time.Year.now
  year = java.time.Year.from(context)
  year.at_month_day(to_month_day)
end

#to_monthself

Returns:

  • (self)


51
52
53
# File 'lib/openhab/core_ext/java/month.rb', line 51

def to_month
  self
end

#to_month_dayMonthDay

Returns:



56
57
58
# File 'lib/openhab/core_ext/java/month.rb', line 56

def to_month_day
  MonthDay.of(self, 1)
end

#to_zoned_date_time(context = nil) ⇒ ZonedDateTime

Parameters:

Returns:



64
65
66
# File 'lib/openhab/core_ext/java/month.rb', line 64

def to_zoned_date_time(context = nil)
  to_local_date(context).to_zoned_date_time(context)
end