Method: Redmine::Database.timestamp_to_date
- Defined in:
- lib/redmine/database.rb
.timestamp_to_date(column, time_zone) ⇒ Object
Returns a SQL statement to cast a timestamp column to a date given a time zone Returns nil if not implemented for the current database
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/redmine/database.rb', line 87 def (column, time_zone) if postgresql? if time_zone identifier = ActiveSupport::TimeZone.find_tzinfo(time_zone.name).identifier "(#{column}::timestamptz AT TIME ZONE '#{identifier}')::date" else "#{column}::date" end elsif mysql? if time_zone user_identifier = ActiveSupport::TimeZone.find_tzinfo(time_zone.name).identifier local_identifier = ActiveSupport::TimeZone.find_tzinfo(Time.zone.name).identifier "DATE(CONVERT_TZ(#{column},'#{local_identifier}', '#{user_identifier}'))" else "DATE(#{column})" end end end |