Class: OpenHAB::CoreExt::Java::MonthDay
  
  
  
  
  
    - Inherits:
 
    - 
      Object
      
        
          - Object
 
          
            - OpenHAB::CoreExt::Java::MonthDay
 
          
        
        show all
      
     
  
  
  
  
  
  
  
      - Includes:
 
      - Between, Ephemeris, Time
 
  
  
  
  
  
  
    - Defined in:
 
    - lib/openhab/core_ext/java/month_day.rb
 
  
  
 
Overview
  
  
    
      Class Method Summary
      collapse
    
    
    
  
    
      Instance Method Summary
      collapse
    
    
    
  
  
  
  
  
  
  
  
  
  Methods included from Time
  #<=>, #coerce
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  Methods included from Ephemeris
  #days_until, #holiday, #holiday?, #in_dayset?, #next_holiday, #weekend?
  
  
  
  
  
  
  
  
  Methods included from Between
  #between?
  
    Class Method Details
    
      
  
  
    .parse(string)  ⇒ MonthDay 
  
  
  
  
    Parses strings in the form "M-d"
   
 
  
    
      
22
23
24
25
26
27 
     | 
    
      # File 'lib/openhab/core_ext/java/month_day.rb', line 22
def parse(string)
  logger.trace("#{self.class}.parse #{string} (#{string.class})")
  java_send(:parse, [java.lang.CharSequence, java.time.format.DateTimeFormatter],
            string.to_s,
            java.time.format.DateTimeFormatter.ofPattern("[--]M-d"))
end
     | 
  
 
    
   
  
    Instance Method Details
    
      
  
  
    
      
41
42
43
44
45
46
47
48 
     | 
    
      # File 'lib/openhab/core_ext/java/month_day.rb', line 41
def +(other)
  case other
  when java.time.temporal.TemporalAmount, Numeric
    (LocalDate.of(1900, month, day_of_month) + other).to_month_day
  else
    (to_local_date(other.to_local_date) + other).to_month_day
  end
end
     | 
  
 
    
      
  
  
    
      
51
52
53
54
55
56
57
58
59
60
61 
     | 
    
      # File 'lib/openhab/core_ext/java/month_day.rb', line 51
def -(other)
  d = case other
      when java.time.temporal.TemporalAmount, Numeric
        LocalDate.of(1900, month, day_of_month) - other
      else
        to_local_date(other.to_local_date) - other
      end
  return d if d.is_a?(java.time.Period)
  d.to_month_day
end
     | 
  
 
    
      
  
  
    Returns the next day
Will go to the next month, or loop back to January if necessary.
   
 
  
    
      
70
71
72
73
74
75
76
77
78 
     | 
    
      # File 'lib/openhab/core_ext/java/month_day.rb', line 70
def succ
  if day_of_month == month.max_length
    return MonthDay.of(1, 1) if month_value == 12
    return MonthDay.of(month_value + 1, 1)
  end
  MonthDay.of(month_value, day_of_month + 1)
end
     | 
  
 
    
      
  
  
    #to_date(context = nil)  ⇒ Date 
  
  
  
  
    
      
97
98
99
100 
     | 
    
      # File 'lib/openhab/core_ext/java/month_day.rb', line 97
def to_date(context = nil)
  context ||= Date.today
  Date.new(context.year, month_value, day_of_month)
end 
     | 
  
 
    
      
  
  
    #to_local_date(context = nil)  ⇒ LocalDate 
  
  
  
  
    
      
84
85
86
87
88 
     | 
    
      # File 'lib/openhab/core_ext/java/month_day.rb', line 84
def to_local_date(context = nil)
  context ||= java.time.Year.now
  year = java.time.Year.from(context)
  year.at_month_day(self)
end 
     | 
  
 
    
      
  
  
    #to_month  ⇒ Month 
  
  
  
  
    
      
91 
     | 
    
      # File 'lib/openhab/core_ext/java/month_day.rb', line 91
alias_method :to_month, :month 
     | 
  
 
    
      
  
  
    #to_month_day  ⇒ self 
  
  
  
  
    
      
103
104
105 
     | 
    
      # File 'lib/openhab/core_ext/java/month_day.rb', line 103
def to_month_day
  self
end 
     | 
  
 
    
      
  
  
    #to_s  ⇒ String 
  
  
    Also known as:
    inspect
    
  
  
  
    
      
31
32
33
34 
     | 
    
      # File 'lib/openhab/core_ext/java/month_day.rb', line 31
def to_s
  
  to_string.delete_prefix("--")
end
     | 
  
 
    
      
  
  
    #to_zoned_date_time(context = nil)  ⇒ ZonedDateTime 
  
  
  
  
    
      
111
112
113 
     | 
    
      # File 'lib/openhab/core_ext/java/month_day.rb', line 111
def to_zoned_date_time(context = nil)
  to_local_date(context).to_zoned_date_time(context)
end 
     |