Class: Date
  
  
  
Overview
  
  
    
      Instance Method Summary
      collapse
    
    
    
  
  
  
  
  
  
  
  
  
  
  #days_until, #holiday, #holiday?, #in_dayset?, #next_holiday, #weekend?
  
  
  
  
  
  
  
  
  
  #between?
  
    Instance Method Details
    
      
  
  
    #coerce(other)  ⇒ Array? 
  
  
  
  
    Convert other to Date, if possible.
   
 
  
    | 
86
87
88
89
90
91 | # File 'lib/openhab/core_ext/ruby/date.rb', line 86
def coerce(other)
  return nil unless other.respond_to?(:to_date)
  return [other.to_date, self] if other.method(:to_date).arity.zero?
  [other.to_date(self), self]
end | 
 
    
      
  
  
    #compare_with_coercion(other)  ⇒ Integer? 
  
  
    Also known as:
    <=>
    
  
  
  
    | 
66
67
68
69
70
71
72
73
74
75
76 | # File 'lib/openhab/core_ext/ruby/date.rb', line 66
def compare_with_coercion(other)
  return compare_without_coercion(other) if other.is_a?(self.class)
  return self <=> other.to_date(self) if other.is_a?(java.time.MonthDay)
  if other.respond_to?(:coerce) && (lhs, rhs = other.coerce(self))
    return lhs <=> rhs
  end
  compare_without_coercion(other)
end | 
 
    
      
  
  
    #inspect  ⇒ String 
  
  
  
  
    | 
95 | # File 'lib/openhab/core_ext/ruby/date.rb', line 95
alias_method :inspect, :to_s | 
 
    
      
  
  
    #minus_with_temporal(other)  ⇒ LocalDate 
  
  
    Also known as:
    -
    
  
  
  
    | 
30
31
32
33
34
35
36
37 | # File 'lib/openhab/core_ext/ruby/date.rb', line 30
def minus_with_temporal(other)
  case other
  when java.time.temporal.TemporalAmount, java.time.LocalDate
    to_local_date - other
  else
    minus_without_temporal(other)
  end
end | 
 
    
      
  
  
    #plus_with_temporal(other)  ⇒ LocalDate 
  
  
    Also known as:
    +
    
  
  
  
    | 
16
17
18
19
20 | # File 'lib/openhab/core_ext/ruby/date.rb', line 16
def plus_with_temporal(other)
  return to_local_date + other if other.is_a?(java.time.temporal.TemporalAmount)
  plus_without_temporal(other)
end | 
 
    
      
  
  
    #to_local_date(_context = nil)  ⇒ LocalDate 
  
  
  
  
    | 
42
43
44 | # File 'lib/openhab/core_ext/ruby/date.rb', line 42
def to_local_date(_context = nil)
  java.time.LocalDate.of(year, month, day)
end | 
 
    
      
  
  
    #to_month  ⇒ Month 
  
  
  
  
    | 
47
48
49 | # File 'lib/openhab/core_ext/ruby/date.rb', line 47
def to_month
  java.time.Month.of(month)
end | 
 
    
      
  
  
    | 
52
53
54 | # File 'lib/openhab/core_ext/ruby/date.rb', line 52
def to_month_day
  java.time.MonthDay.of(month, day)
end | 
 
    
      
  
  
    #to_zoned_date_time(context = nil)  ⇒ ZonedDateTime 
  
  
  
  
    | 
61
62
63 | # File 'lib/openhab/core_ext/ruby/date.rb', line 61
def to_zoned_date_time(context = nil)
  to_local_date.to_zoned_date_time(context)
end |