Class: Rack::TimeZoneHeader

Inherits:
Object
  • Object
show all
Defined in:
lib/rack/time_zone_header.rb,
lib/rack/time_zone_header/version.rb

Defined Under Namespace

Modules: VERSION

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ TimeZoneHeader

Returns a new instance of TimeZoneHeader.



9
10
11
# File 'lib/rack/time_zone_header.rb', line 9

def initialize(app)
  @app = app
end

Instance Method Details

#call(env) ⇒ Object



13
14
15
16
17
18
# File 'lib/rack/time_zone_header.rb', line 13

def call(env)
  header = env["HTTP_TIME_ZONE"] || env["HTTP_X_TIME_ZONE"] || env["HTTP_TIMEZONE"]
  zone = TZInfo::Timezone.get(header.split(";").last) rescue nil
  env["time.zone"] = zone if zone
  @app.call(env)
end