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
178 def literal_date(date)
179   if date < DATE_YEAR_1
180     date <<= ((date.year) * 24 - 12)
181     date.strftime("'%Y-%m-%d BC'")
182   else
183     super
184   end
185 end
literal_datetime(date) click to toggle source

Handle BC DateTime objects.

Calls superclass method
    # File lib/sequel/extensions/pg_extended_date_support.rb
188 def literal_datetime(date)
189   if date < DATETIME_YEAR_1
190     date <<= ((date.year) * 24 - 12)
191     date = db.from_application_timestamp(date)
192     minutes = (date.is_a?(DateTime) ? date.offset * 1440 : date.utc_offset/60).to_i
193     date.strftime("'%Y-%m-%d %H:%M:%S.%N#{format_timestamp_offset(*minutes.divmod(60))} BC'")
194   else
195     super
196   end
197 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
200 def literal_other_append(sql, v)
201   if v.is_a?(Date::Infinity)
202     sql << (v > 0 ? "'infinity'" : "'-infinity'")
203   else
204     super
205   end
206 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
224 def literal_time(time)
225   if time < TIME_YEAR_1
226     dt = DateTime.parse(super)
227     # Work around JRuby bug #5191
228     dt >>= 12 if JRUBY_VERSION == '9.2.0.0'
229     literal_datetime(dt)
230   else
231     super
232   end
233 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
214 def type_convertor(map, meta, type, i)
215   case type
216   when *CONVERT_TYPES
217     db.oid_convertor_proc(meta.getField(i).getOID)
218   else
219     super
220   end
221 end