Class: Rack::TimeZone
- Inherits:
-
Object
- Object
- Rack::TimeZone
- Defined in:
- lib/rack/contrib/time_zone.rb
Constant Summary collapse
- Javascript =
<<-EOJ function setTimezoneCookie() { var offset = (new Date()).getTimezoneOffset() var date = new Date(); date.setTime(date.getTime()+3600000); document.cookie = "utc_offset="+offset+"; expires="+date.toGMTString();+"; path=/"; } EOJ
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app) ⇒ TimeZone
constructor
A new instance of TimeZone.
Constructor Details
#initialize(app) ⇒ TimeZone
Returns a new instance of TimeZone.
14 15 16 |
# File 'lib/rack/contrib/time_zone.rb', line 14 def initialize(app) @app = app end |
Instance Method Details
#call(env) ⇒ Object
18 19 20 21 22 23 24 25 |
# File 'lib/rack/contrib/time_zone.rb', line 18 def call(env) request = Rack::Request.new(env) if utc_offset = request.["utc_offset"] env["rack.timezone.utc_offset"] = -(utc_offset.to_i * 60) end @app.call(env) end |