-
-
Save ArturT/8804428 to your computer and use it in GitHub Desktop.
don't change non DateTime
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rails_admin/config/fields/base' | |
module RailsAdmin | |
module Config | |
module Fields | |
module Types | |
class Datetime < RailsAdmin::Config::Fields::Base | |
def value | |
value_in_default_time_zone = bindings[:object].send(name) | |
return nil if value_in_default_time_zone.nil? | |
if value_in_default_time_zone.is_a?(DateTime) | |
pacific_time_zone = ActiveSupport::TimeZone.new('US/Pacific') | |
value_in_default_time_zone.in_time_zone(pacific_time_zone) | |
else | |
value_in_default_time_zone | |
end | |
end | |
end | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment