Class: OpenHAB::CoreExt::Java::LocalDate
Overview
Class Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Ephemeris
#days_until, #holiday, #holiday?, #in_dayset?, #next_holiday, #weekend?
Methods included from Between
#between?
#within?
Methods included from Time
#<=>, #coerce
Class Attribute Details
|
# File 'lib/openhab/core_ext/java/local_date.rb', line 19
|
Class Method Details
.parse(text, formatter = nil) ⇒ LocalDate
Converts the given text into a LocalDate.
|
# File 'lib/openhab/core_ext/java/local_date.rb', line 22
|
Instance Method Details
56
57
58
59
60
61
62
63
64
65
66
67
|
# File 'lib/openhab/core_ext/java/local_date.rb', line 56
def +(other)
case other
when Duration
plus_days(other.to_days)
when Numeric
plus_days(other.to_i)
when QuantityType
plus_days(other.to_temporal_amount.to_days)
else
plus(other)
end
end
|
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
# File 'lib/openhab/core_ext/java/local_date.rb', line 34
def -(other)
case other
when Date
self - other.to_local_date
when MonthDay
self - other.at_year(year)
when LocalDate
Period.between(other, self)
when Duration
minus_days(other.to_days)
when Numeric
minus_days(other.ceil)
when QuantityType
minus_days(other.to_temporal_amount.to_days)
else
minus(other)
end
end
|
74
75
76
|
# File 'lib/openhab/core_ext/java/local_date.rb', line 74
def succ
plus_days(1)
end
|
#to_date ⇒ Date
79
80
81
|
# File 'lib/openhab/core_ext/java/local_date.rb', line 79
def to_date
Date.new(year, month_value, day_of_month)
end
|
#to_instant(context = nil) ⇒ Instant
109
110
111
|
# File 'lib/openhab/core_ext/java/local_date.rb', line 109
def to_instant(context = nil)
to_zoned_date_time(context).to_instant
end
|
#to_local_date(_context = nil) ⇒ self
92
93
94
|
# File 'lib/openhab/core_ext/java/local_date.rb', line 92
def to_local_date(_context = nil)
self
end
|
#to_month ⇒ Month
84
|
# File 'lib/openhab/core_ext/java/local_date.rb', line 84
alias_method :to_month, :month
|
87
88
89
|
# File 'lib/openhab/core_ext/java/local_date.rb', line 87
def to_month_day
MonthDay.of(month, day_of_month)
end
|
#to_zoned_date_time(context = nil) ⇒ ZonedDateTime
100
101
102
103
|
# File 'lib/openhab/core_ext/java/local_date.rb', line 100
def to_zoned_date_time(context = nil)
zone = context&.zone || java.time.ZoneId.system_default
at_start_of_day(zone)
end
|