File: named_timezones.rb [sequel-3.12.0 Documentation]

Last Modified
  2018-01-01 00:18:20 +0000
Requires
  - tzinfo

## Description

Allows the use of named timezones via TZInfo (requires tzinfo). Forces the use of DateTime as Sequel’s datetime_class, since ruby’s Time class doesn’t support timezones other than local and UTC.

This allows you to either pass strings or TZInfo::Timezone instance to Sequel.database_timezone=, application_timezone=, and typecast_timezone=. If a string is passed, it is converted to a TZInfo::Timezone using TZInfo::Timezone.get.

Let’s say you have the database server in New York and the application server in Los Angeles. For historical reasons, data is stored in local New York time, but the application server only services clients in Los Angeles, so you want to use New York time in the database and Los Angeles time in the application. This is easily done via:

    Sequel.database_timezone = 'America/New_York'
    Sequel.application_timezone = 'America/Los_Angeles'

Then, before data is stored in the database, it is converted to New York time. When data is retrieved from the database, it is converted to Los Angeles time.