| Class | Informix::IntervalYTM |
| In: |
lib/informix/interval.rb
|
| Parent: | IntervalBase |
The IntervalYTM class is an Interval class dedicated only to represent intervals in the scope YEAR TO MONTH.
| months | [R] | |
| years | [R] |
Creates an IntervalYTM object with val as value.
IntervalYTM.new(val) => interval
# File lib/informix/interval.rb, line 106
106: def initialize(val)
107: super
108: @val = val.to_i
109: @years, @months = @val.abs.divmod 12
110: if @val < 0
111: @years = -@years
112: @months = -@months
113: end
114: @fields = [ @years, @months ]
115: end
interval + date => date interval + datetime => datetime
# File lib/informix/interval.rb, line 119
119: def +(obj)
120: case obj
121: when Date, DateTime
122: obj >> @val
123: else
124: super
125: end
126: end
Converts invl to months
invl.to_months => numeric
# File lib/informix/interval.rb, line 141
141: def to_months; @val end
Returns an ANSI SQL standards compliant string representation
invl.to_s => string
# File lib/informix/interval.rb, line 131
131: def to_s; "%d-%02d" % [@years, @months.abs] end