module Sequel::Postgres::ExtendedDateSupport::DatasetMethods

Private Instance Methods

literal_date(date) click to toggle source

Handle BC Date objects.

Calls superclass method
    # File lib/sequel/extensions/pg_extended_date_support.rb
171 def literal_date(date)
172   if date < DATE_YEAR_1
173     date <<= ((date.year) * 24 - 12)
174     date.strftime("'%Y-%m-%d BC'")
175   else
176     super
177   end
178 end
literal_datetime(date) click to toggle source

Handle BC DateTime objects.

Calls superclass method
    # File lib/sequel/extensions/pg_extended_date_support.rb
181 def literal_datetime(date)
182   if date < DATETIME_YEAR_1
183     date <<= ((date.year) * 24 - 12)
184     date = db.from_application_timestamp(date)
185     minutes = (date.is_a?(DateTime) ? date.offset * 1440 : date.utc_offset/60).to_i
186     date.strftime("'%Y-%m-%d %H:%M:%S.%N#{format_timestamp_offset(*minutes.divmod(60))} BC'")
187   else
188     super
189   end
190 end
literal_other_append(sql, v) click to toggle source

Handle Date::Infinity values

Calls superclass method
    # File lib/sequel/extensions/pg_extended_date_support.rb
193 def literal_other_append(sql, v)
194   if v.is_a?(Date::Infinity)
195     sql << (v > 0 ? "'infinity'" : "'-infinity'")
196   else
197     super
198   end
199 end
literal_time(time) click to toggle source

Work around JRuby bug #4822 in Time#to_datetime for times before date of calendar reform

Calls superclass method
    # File lib/sequel/extensions/pg_extended_date_support.rb
217 def literal_time(time)
218   if time < TIME_YEAR_1
219     dt = DateTime.parse(super)
220     # Work around JRuby bug #5191
221     dt >>= 12 if JRUBY_VERSION == '9.2.0.0'
222     literal_datetime(dt)
223   else
224     super
225   end
226 end
type_convertor(map, meta, type, i) click to toggle source

Use non-JDBC parsing as JDBC parsing doesn't work for BC dates/timestamps.

Calls superclass method
    # File lib/sequel/extensions/pg_extended_date_support.rb
207 def type_convertor(map, meta, type, i)
208   case type
209   when *CONVERT_TYPES
210     db.oid_convertor_proc(meta.getField(i).getOID)
211   else
212     super
213   end
214 end