Module: Sequel::Timezones

Included in:
Sequel
Defined in:
lib/sequel/lib/sequel/timezones.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#application_timezoneObject (readonly)

Returns the value of attribute application_timezone


13
14
15
# File 'lib/sequel/lib/sequel/timezones.rb', line 13

def application_timezone
  @application_timezone
end

#database_timezoneObject (readonly)

Returns the value of attribute database_timezone


13
14
15
# File 'lib/sequel/lib/sequel/timezones.rb', line 13

def database_timezone
  @database_timezone
end

#typecast_timezoneObject (readonly)

Returns the value of attribute typecast_timezone


13
14
15
# File 'lib/sequel/lib/sequel/timezones.rb', line 13

def typecast_timezone
  @typecast_timezone
end

Instance Method Details

#application_to_database_timestamp(v) ⇒ Object

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


21
22
23
# File 'lib/sequel/lib/sequel/timezones.rb', line 21

def application_to_database_timestamp(v)
  convert_output_timestamp(v, Sequel.database_timezone)
end

#database_to_application_timestamp(v) ⇒ Object

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.


28
29
30
# File 'lib/sequel/lib/sequel/timezones.rb', line 28

def database_to_application_timestamp(v)
  convert_timestamp(v, Sequel.database_timezone)
end

#default_timezone=(tz) ⇒ Object

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


33
34
35
36
37
# File 'lib/sequel/lib/sequel/timezones.rb', line 33

def default_timezone=(tz)
  self.database_timezone = tz
  self.application_timezone = tz
  self.typecast_timezone = tz
end

#typecast_to_application_timestamp(v) ⇒ Object

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.


42
43
44
# File 'lib/sequel/lib/sequel/timezones.rb', line 42

def typecast_to_application_timestamp(v)
  convert_timestamp(v, Sequel.typecast_timezone)
end