module Sequel
Plugin for adding methods for working with time ranges.
Example¶ ↑
Defining a model class with a timestamptz range:
class ACME::Lease < Sequel::Model(:leases) plugin :tstzrange_fields, :active_during
And in the schema:
create_table(:leases) do primary_key :id tstzrange :active_during end
You can use it as follows:
lease = ACME::Lease.new lease.active_during_begin = Time.now lease.active_during_end = 1.year.from_now lease.active_during = 1.year.ago..1.year.from_now lease.active_during_end = nil # Unbounded end set lease.active_during = nil # Empty set