Class: OpenHAB::CoreExt::Java::Month
- Inherits:
-
Object
- Object
- OpenHAB::CoreExt::Java::Month
- Includes:
- Between, Time, TimePredicates
- Defined in:
- lib/openhab/core_ext/java/month.rb
Overview
Extensions to java.time.Month
Instance Method Summary collapse
- #+(other) ⇒ Month
- #-(other) ⇒ Month
-
#succ ⇒ Month
Returns the next month.
- #to_date(context = nil) ⇒ Date
- #to_instant(context = nil) ⇒ Instant
- #to_local_date(context = nil) ⇒ LocalDate
- #to_month ⇒ self
- #to_month_day ⇒ MonthDay
- #to_zoned_date_time(context = nil) ⇒ ZonedDateTime
Methods included from Time
Methods included from Between
Methods included from TimePredicates
Instance Method Details
#+(other) ⇒ Month
18 19 20 |
# File 'lib/openhab/core_ext/java/month.rb', line 18 def +(other) plus(other) end |
#-(other) ⇒ Month
23 24 25 |
# File 'lib/openhab/core_ext/java/month.rb', line 23 def -(other) minus(other) end |
#succ ⇒ Month
Returns the next month
Will loop back to January if necessary.
34 35 36 |
# File 'lib/openhab/core_ext/java/month.rb', line 34 def succ plus(1) end |
#to_date(context = nil) ⇒ Date
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
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
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_month ⇒ self
51 52 53 |
# File 'lib/openhab/core_ext/java/month.rb', line 51 def to_month self end |
#to_month_day ⇒ MonthDay
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
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 |