Sha256: 62c0f19aa711ef64e072d1a265a929504b7de9f13eb816a6c686129dbde79dd8

Contents?: true

Size: 589 Bytes

Versions: 37

Compression:

Stored size: 589 Bytes

Contents

module Rack
  class TimeZone
    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

    def initialize(app)
      @app = app
    end

    def call(env)
      request = Rack::Request.new(env)
      if utc_offset = request.cookies["utc_offset"]
        env["rack.timezone.utc_offset"] = -(utc_offset.to_i * 60)
      end

      @app.call(env)
    end
  end
end

Version data entries

37 entries across 37 versions & 9 rubygems

Version Path
rack-contrib-2.2.0 lib/rack/contrib/time_zone.rb
rack-contrib-2.1.0 lib/rack/contrib/time_zone.rb
rack-contrib-2.0.1 lib/rack/contrib/time_zone.rb
rack-contrib-2.0.0 lib/rack/contrib/time_zone.rb
rack-contrib-1.8.0 lib/rack/contrib/time_zone.rb
rack-contrib-1.7.0 lib/rack/contrib/time_zone.rb
rack-contrib-1.6.0 lib/rack/contrib/time_zone.rb
rack-contrib-1.5.0 lib/rack/contrib/time_zone.rb
rack-contrib-1.4.0 lib/rack/contrib/time_zone.rb
rack-contrib-1.3.0 lib/rack/contrib/time_zone.rb
rack-contrib-1.2.0.39.g17d21b4 lib/rack/contrib/time_zone.rb
rack-contrib-1.2.0 lib/rack/contrib/time_zone.rb
cavalle-rack-contrib-1.0.0 lib/rack/contrib/time_zone.rb
rack-rack-contrib-0.9.1 lib/rack/contrib/time_zone.rb
rack-rack-contrib-0.9.2 lib/rack/contrib/time_zone.rb
rtomayko-rack-contrib-0.4.0 lib/rack/time_zone.rb
tricycle-rack-contrib-0.9.3 lib/rack/contrib/time_zone.rb
rack-contrib-1.1.0 lib/rack/contrib/time_zone.rb
corntrace-rack-contrib-1.0.2.3 lib/rack/contrib/time_zone.rb
corntrace-rack-contrib-1.0.2.2 lib/rack/contrib/time_zone.rb