add full IANA time zone support
This commit is contained in:
parent
341a49d3e9
commit
5f69a17f9e
2
Gemfile
2
Gemfile
@ -33,6 +33,8 @@ gem 'activeadmin', github: 'gregbell/active_admin'
|
||||
gem 'chronic'
|
||||
gem 'non-stupid-digest-assets'
|
||||
gem 'em-http-request'
|
||||
gem 'tzinfo'
|
||||
gem 'tzinfo-data'
|
||||
|
||||
# to use debugger
|
||||
# gem 'ruby-debug'
|
||||
|
@ -322,6 +322,7 @@ GEM
|
||||
multi_json (~> 1.0)
|
||||
simple_oauth (~> 0.2)
|
||||
tzinfo (0.3.39)
|
||||
tzinfo-data (1.2013.9)
|
||||
uglifier (2.4.0)
|
||||
execjs (>= 0.3.0)
|
||||
json (>= 1.8.0)
|
||||
@ -386,6 +387,8 @@ DEPENDENCIES
|
||||
therubyracer
|
||||
tweetstream
|
||||
twitter_oauth!
|
||||
tzinfo
|
||||
tzinfo-data
|
||||
uglifier
|
||||
webrat
|
||||
will_paginate (~> 3.0.pre2)
|
||||
|
@ -315,7 +315,11 @@ class ApplicationController < ActionController::Base
|
||||
# set timezone correctly
|
||||
def set_time_zone
|
||||
if params[:timezone].present?
|
||||
Time.zone = ActiveSupport::TimeZone::MAPPING.key(params[:timezone])
|
||||
begin
|
||||
Time.zone = TZInfo::Timezone.get(params[:timezone])
|
||||
rescue
|
||||
Time.zone = 'UTC'
|
||||
end
|
||||
elsif params[:offset].present?
|
||||
Time.zone = set_timezone_from_offset(params[:offset])
|
||||
elsif current_user.present?
|
||||
|
@ -39,6 +39,9 @@
|
||||
<br><br>
|
||||
<pre>GET <span class="str"><%= @ssl_api_domain %>channels/9/fields/1/last.json?timezone=<span class="customcode">America%2FNew_York</span></span></pre>
|
||||
<br>
|
||||
The most common time zone identifiers are listed below. ThingSpeak supports all <a href="http://www.iana.org/time-zones" target="_blank">IANA Time Zone Database</a>
|
||||
identifers; a <a href="http://twiki.org/cgi-bin/xtra/tzdatepick.html" target="_blank">human-readable list</a> is also available.
|
||||
<br><br>
|
||||
<table class="table table-striped table-bordered table-condensed">
|
||||
<tr>
|
||||
<th>Identifier</th>
|
||||
|
Loading…
Reference in New Issue
Block a user