Class: OpenHAB::CoreExt::Java::LocalDate
- Inherits:
-
Object
- Object
- OpenHAB::CoreExt::Java::LocalDate
show all
- Includes:
- Between, Ephemeris, Time
- Defined in:
- lib/openhab/core_ext/java/local_date.rb
Overview
Extensions to javajava.timejava.time.LocalDate
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?
Methods included from Time
#<=>, #coerce
Class Attribute Details
|
# File 'lib/openhab/core_ext/java/local_date.rb', line 18
|
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 21
|
Instance Method Details
53
54
55
56
57
58
59
60
61
62
|
# File 'lib/openhab/core_ext/java/local_date.rb', line 53
def +(other)
case other
when Duration
plus_days(other.to_days)
when Numeric
plus_days(other.to_i)
else
plus(other)
end
end
|
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
# File 'lib/openhab/core_ext/java/local_date.rb', line 33
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)
else
minus(other)
end
end
|
69
70
71
|
# File 'lib/openhab/core_ext/java/local_date.rb', line 69
def succ
plus_days(1)
end
|
#to_date ⇒ Date
74
75
76
|
# File 'lib/openhab/core_ext/java/local_date.rb', line 74
def to_date
Date.new(year, month_value, day_of_month)
end
|
#to_instant(context = nil) ⇒ Instant
104
105
106
107
|
# File 'lib/openhab/core_ext/java/local_date.rb', line 104
def to_instant(context = nil)
zone = context&.zone || java.time.ZoneOffset::UTC
at_start_of_day(zone).to_instant
end
|
#to_local_date(_context = nil) ⇒ self
87
88
89
|
# File 'lib/openhab/core_ext/java/local_date.rb', line 87
def to_local_date(_context = nil)
self
end
|
82
83
84
|
# File 'lib/openhab/core_ext/java/local_date.rb', line 82
def to_month_day
MonthDay.of(month, day_of_month)
end
|
#to_zoned_date_time(context = nil) ⇒ ZonedDateTime
95
96
97
98
|
# File 'lib/openhab/core_ext/java/local_date.rb', line 95
def to_zoned_date_time(context = nil)
zone = context&.zone || java.time.ZoneId.system_default
at_start_of_day(zone)
end
|