Class: OpenHAB::CoreExt::Java::Month
- Inherits:
-
Object
- Object
- OpenHAB::CoreExt::Java::Month
- Defined in:
- lib/openhab/core_ext/java/month.rb
Overview
Extensions to javajava.timejava.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
Instance Method Details
#+(other) ⇒ Month
16 17 18 |
# File 'lib/openhab/core_ext/java/month.rb', line 16 def +(other) plus(other) end |
#-(other) ⇒ Month
21 22 23 |
# File 'lib/openhab/core_ext/java/month.rb', line 21 def -(other) minus(other) end |
#succ ⇒ Month
Returns the next month
Will loop back to January if necessary.
32 33 34 |
# File 'lib/openhab/core_ext/java/month.rb', line 32 def succ plus(1) end |
#to_date(context = nil) ⇒ Date
44 45 46 |
# File 'lib/openhab/core_ext/java/month.rb', line 44 def to_date(context = nil) to_local_date(context).to_date end |
#to_instant(context = nil) ⇒ Instant
71 72 73 74 |
# File 'lib/openhab/core_ext/java/month.rb', line 71 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
37 38 39 40 41 |
# File 'lib/openhab/core_ext/java/month.rb', line 37 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
49 50 51 |
# File 'lib/openhab/core_ext/java/month.rb', line 49 def to_month self end |
#to_month_day ⇒ MonthDay
54 55 56 |
# File 'lib/openhab/core_ext/java/month.rb', line 54 def to_month_day MonthDay.of(self, 1) end |
#to_zoned_date_time(context = nil) ⇒ ZonedDateTime
62 63 64 |
# File 'lib/openhab/core_ext/java/month.rb', line 62 def to_zoned_date_time(context = nil) to_local_date(context).to_zoned_date_time(context) end |