Module | Sequel::Timezones
In: | lib/sequel/timezones.rb

Sequel doesn‘t pay much attention to timezones by default, but you can set it handle timezones if you want. There are three separate timezone settings, application_timezone, database_timezone, and typecast_timezone. All three timezones have getter and setter methods. You can set all three timezones to the same value at once via `Sequel.default_timezone=`.

The only timezone values that are supported by default are `:utc` (convert to UTC), `:local` (convert to local time), and `nil` (don‘t convert). If you need to convert to a specific timezone, or need the timezones being used to change based on the environment (e.g. current user), you need to use the `named_timezones` extension (and use `DateTime` as the `datetime_class`). Sequel also ships with a `thread_local_timezones` extensions which allows each thread to have its own timezone values for each of the timezones.

### Methods

application_to_database_timestamp database_to_application_timestamp default_timezone= typecast_to_application_timestamp

### Attributes

application_timezone | [R] | The timezone you want the application to use. This is the timezone that incoming times from the database and typecasting are converted to.
database_timezone | [R] | The timezone for storage in the database. This is the timezone to which Sequel will convert timestamps before literalizing them for storage in the database. It is also the timezone that Sequel will assume database timestamp values are already in (if they don‘t include an offset).
typecast_timezone | [R] | The timezone that incoming data that Sequel needs to typecast is assumed to be already in (if they don‘t include an offset).

### Public Instance methods

application_to_database_timestamp(v)

Convert the given `Time`/`DateTime` object into the database timezone, used when literalizing objects in an SQL string.

[Source]

        # File lib/sequel/timezones.rb, line 38
    38:     def application_to_database_timestamp(v)
    39:       convert_output_timestamp(v, Sequel.database_timezone)
    40:     end

database_to_application_timestamp(v)

Convert the given object into an object of `Sequel.datetime_class` in the `application_timezone`. Used when coverting datetime/timestamp columns returned by the database.

[Source]

        # File lib/sequel/timezones.rb, line 45
    45:     def database_to_application_timestamp(v)
    46:       convert_timestamp(v, Sequel.database_timezone)
    47:     end

default_timezone=(tz)

Sets the database, application, and typecasting timezones to the given timezone.

[Source]

        # File lib/sequel/timezones.rb, line 50
    50:     def default_timezone=(tz)
    51:       self.database_timezone = tz
    52:       self.application_timezone = tz
    53:       self.typecast_timezone = tz
    54:     end

typecast_to_application_timestamp(v)

Convert the given object into an object of `Sequel.datetime_class` in the `application_timezone`. Used when typecasting values when assigning them to model datetime attributes.

[Source]

        # File lib/sequel/timezones.rb, line 59
    59:     def typecast_to_application_timestamp(v)
    60:       convert_timestamp(v, Sequel.typecast_timezone)
    61:     end

[Validate]