time_with_zone 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 6d27f1acaf295afd5e700334e3935da2c438b3c5
4
+ data.tar.gz: 231c3fe2fe85de8d9f49d88d71cc17170c9bd19c
5
+ SHA512:
6
+ metadata.gz: 5e95538172fae1e99a461f8d235a7d652ea81b8dc3beb13d9b0e4e430096f4c03fe9cf1cda830adeb8b529a5cc5466f477f5040b6ea98ff7712e0255df6ed6ab
7
+ data.tar.gz: 883ee12f1cf8a1bf0ebaecf1dee1b30a29248dbd4906cc3738de9e228a00302379c155d61821e54391db5d4d1c049d857058bdeed05b8ade3202faf5011dd033
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,6 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.1
4
+ - 2.2
5
+ - 2.3
6
+ before_install: gem install bundler -v 1.11.2
data/.yardopts ADDED
@@ -0,0 +1,6 @@
1
+ --no-private
2
+ --protected
3
+ --output-dir docs
4
+ -
5
+ README.md
6
+ LICENSE.txt
data/CHANGELOG.md ADDED
@@ -0,0 +1,3 @@
1
+ # 0.1.0 (2016-10-30
2
+
3
+ First version
@@ -0,0 +1,49 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, and in the interest of
4
+ fostering an open and welcoming community, we pledge to respect all people who
5
+ contribute through reporting issues, posting feature requests, updating
6
+ documentation, submitting pull requests or patches, and other activities.
7
+
8
+ We are committed to making participation in this project a harassment-free
9
+ experience for everyone, regardless of level of experience, gender, gender
10
+ identity and expression, sexual orientation, disability, personal appearance,
11
+ body size, race, ethnicity, age, religion, or nationality.
12
+
13
+ Examples of unacceptable behavior by participants include:
14
+
15
+ * The use of sexualized language or imagery
16
+ * Personal attacks
17
+ * Trolling or insulting/derogatory comments
18
+ * Public or private harassment
19
+ * Publishing other's private information, such as physical or electronic
20
+ addresses, without explicit permission
21
+ * Other unethical or unprofessional conduct
22
+
23
+ Project maintainers have the right and responsibility to remove, edit, or
24
+ reject comments, commits, code, wiki edits, issues, and other contributions
25
+ that are not aligned to this Code of Conduct, or to ban temporarily or
26
+ permanently any contributor for other behaviors that they deem inappropriate,
27
+ threatening, offensive, or harmful.
28
+
29
+ By adopting this Code of Conduct, project maintainers commit themselves to
30
+ fairly and consistently applying these principles to every aspect of managing
31
+ this project. Project maintainers who do not follow or enforce the Code of
32
+ Conduct may be permanently removed from the project team.
33
+
34
+ This code of conduct applies both within project spaces and in public spaces
35
+ when an individual is representing the project or its community.
36
+
37
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
38
+ reported by contacting a project maintainer at sonots@gmail.com. All
39
+ complaints will be reviewed and investigated and will result in a response that
40
+ is deemed necessary and appropriate to the circumstances. Maintainers are
41
+ obligated to maintain confidentiality with regard to the reporter of an
42
+ incident.
43
+
44
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
45
+ version 1.3.0, available at
46
+ [http://contributor-covenant.org/version/1/3/0/][version]
47
+
48
+ [homepage]: http://contributor-covenant.org
49
+ [version]: http://contributor-covenant.org/version/1/3/0/
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
4
+ gem 'pry-nav'
5
+ gem 'yard'
6
+ gem 'test-unit'
7
+ gem 'test-unit-power_assert'
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Naotoshi Seo
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,56 @@
1
+ # TimeWithZone
2
+
3
+ Handle Time with Timezone without ActiveSupport or `ENV['TZ']` for thread-safety.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'time_with_zone'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install time_with_zone
20
+
21
+ ## Usage
22
+
23
+ See [docs](https://sonots.github.io/time_with_zone/frames.html)
24
+
25
+ ## Development
26
+
27
+ ### Run test
28
+
29
+ ```
30
+ bundle exec rake
31
+ ```
32
+
33
+ ### Generate yardoc
34
+
35
+ ```
36
+ bundle exec yard
37
+ ```
38
+
39
+ ### Release
40
+
41
+ ```
42
+ bundle exec rake release
43
+ ```
44
+
45
+ ## CHANGELOG
46
+
47
+ [CHANGELOG.md](./CHANGELOG.md)
48
+
49
+ ## Contributing
50
+
51
+ Bug reports and pull requests are welcome on GitHub at https://github.com/sonots/time_with_zone. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
52
+
53
+
54
+ ## License
55
+
56
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ require "bundler/gem_tasks"
2
+
3
+ require 'rake/testtask'
4
+ desc 'Run test_unit'
5
+ Rake::TestTask.new(:test) do |t|
6
+ t.libs << "test"
7
+ t.test_files = Dir["test/**/test_*.rb"].sort
8
+ t.verbose = true
9
+ t.warning = true
10
+ end
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "time_with_zone"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,1091 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4
+ <head>
5
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
6
+ <title>
7
+ Class: TimeWithZone
8
+
9
+ &mdash; Documentation by YARD 0.8.7.6
10
+
11
+ </title>
12
+
13
+ <link rel="stylesheet" href="css/style.css" type="text/css" charset="utf-8" />
14
+
15
+ <link rel="stylesheet" href="css/common.css" type="text/css" charset="utf-8" />
16
+
17
+ <script type="text/javascript" charset="utf-8">
18
+ hasFrames = window.top.frames.main ? true : false;
19
+ relpath = '';
20
+ framesUrl = "frames.html#!TimeWithZone.html";
21
+ </script>
22
+
23
+
24
+ <script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
25
+
26
+ <script type="text/javascript" charset="utf-8" src="js/app.js"></script>
27
+
28
+
29
+ </head>
30
+ <body>
31
+ <div id="header">
32
+ <div id="menu">
33
+
34
+ <a href="_index.html">Index (T)</a> &raquo;
35
+
36
+
37
+ <span class="title">TimeWithZone</span>
38
+
39
+
40
+ <div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div>
41
+ </div>
42
+
43
+ <div id="search">
44
+
45
+ <a class="full_list_link" id="class_list_link"
46
+ href="class_list.html">
47
+ Class List
48
+ </a>
49
+
50
+ <a class="full_list_link" id="method_list_link"
51
+ href="method_list.html">
52
+ Method List
53
+ </a>
54
+
55
+ <a class="full_list_link" id="file_list_link"
56
+ href="file_list.html">
57
+ File List
58
+ </a>
59
+
60
+ </div>
61
+ <div class="clear"></div>
62
+ </div>
63
+
64
+ <iframe id="search_frame"></iframe>
65
+
66
+ <div id="content"><h1>Class: TimeWithZone
67
+
68
+
69
+
70
+ </h1>
71
+
72
+ <dl class="box">
73
+
74
+ <dt class="r1">Inherits:</dt>
75
+ <dd class="r1">
76
+ <span class="inheritName">Object</span>
77
+
78
+ <ul class="fullTree">
79
+ <li>Object</li>
80
+
81
+ <li class="next">TimeWithZone</li>
82
+
83
+ </ul>
84
+ <a href="#" class="inheritanceTree">show all</a>
85
+
86
+ </dd>
87
+
88
+
89
+
90
+
91
+
92
+
93
+
94
+
95
+
96
+ <dt class="r2 last">Defined in:</dt>
97
+ <dd class="r2 last">lib/time_with_zone.rb<span class="defines">,<br />
98
+ lib/time_with_zone/version.rb</span>
99
+ </dd>
100
+
101
+ </dl>
102
+ <div class="clear"></div>
103
+
104
+
105
+ <h2>Constant Summary</h2>
106
+
107
+ <dl class="constants">
108
+
109
+ <dt id="NUMERIC_PATTERN-constant" class="">NUMERIC_PATTERN =
110
+ <div class="docstring">
111
+ <div class="discussion">
112
+
113
+ <p>[+-]HH:MM, [+-]HHMM, [+-]HH</p>
114
+
115
+
116
+ </div>
117
+ </div>
118
+ <div class="tags">
119
+
120
+
121
+ </div>
122
+ </dt>
123
+ <dd><pre class="code"><span class='tstring'><span class='regexp_beg'>%r{</span><span class='tstring_content'>\A[+-]\d\d(:?\d\d)?\z</span><span class='regexp_end'>}</span></span></pre></dd>
124
+
125
+ <dt id="NAME_PATTERN-constant" class="">NAME_PATTERN =
126
+ <div class="docstring">
127
+ <div class="discussion">
128
+
129
+ <p>Region/Zone, Region/Zone/Zone</p>
130
+
131
+
132
+ </div>
133
+ </div>
134
+ <div class="tags">
135
+
136
+
137
+ </div>
138
+ </dt>
139
+ <dd><pre class="code"><span class='tstring'><span class='regexp_beg'>%r{</span><span class='tstring_content'>\A[^/]+/[^/]+(/[^/]+)?\z</span><span class='regexp_end'>}</span></span></pre></dd>
140
+
141
+ <dt id="ZoneOffset-constant" class="">ZoneOffset =
142
+ <div class="docstring">
143
+ <div class="discussion">
144
+
145
+ <p>Short-abbreviation timezone which Ruby&#39;s Time class supports</p>
146
+
147
+
148
+ </div>
149
+ </div>
150
+ <div class="tags">
151
+
152
+
153
+ <p class="tag_title">See Also:</p>
154
+ <ul class="see">
155
+
156
+ <li><a href="https://github.com/ruby/ruby/blob/6ce158ba870eb815ba9775ac8380b32fd81be040/lib/time.rb#L97-L113" target="_parent" title="https://github.com/ruby/ruby/blob/6ce158ba870eb815ba9775ac8380b32fd81be040/lib/time.rb#L97-L113">https://github.com/ruby/ruby/blob/6ce158ba870eb815ba9775ac8380b32fd81be040/lib/time.rb#L97-L113</a></li>
157
+
158
+ </ul>
159
+
160
+ </div>
161
+ </dt>
162
+ <dd><pre class="code"><span class='lparen'>(</span><span class='kw'>class</span> <span class='op'>&lt;&lt;</span> <span class='const'>Time</span><span class='semicolon'>;</span> <span class='kw'>self</span><span class='semicolon'>;</span> <span class='kw'>end</span><span class='rparen'>)</span><span class='op'>::</span><span class='const'>ZoneOffset</span></pre></dd>
163
+
164
+ <dt id="VERSION-constant" class="">VERSION =
165
+
166
+ </dt>
167
+ <dd><pre class="code"><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>0.1.0</span><span class='tstring_end'>&quot;</span></span></pre></dd>
168
+
169
+ </dl>
170
+
171
+
172
+
173
+
174
+
175
+
176
+
177
+
178
+
179
+ <h2>
180
+ Class Method Summary
181
+ <small>(<a href="#" class="summary_toggle">collapse</a>)</small>
182
+ </h2>
183
+
184
+ <ul class="summary">
185
+
186
+ <li class="public ">
187
+ <span class="summary_signature">
188
+
189
+ <a href="#localtime_with_zone-class_method" title="localtime_with_zone (class method)">+ (Object) <strong>localtime_with_zone</strong>(time, timezone) </a>
190
+
191
+
192
+
193
+ </span>
194
+
195
+
196
+
197
+
198
+
199
+
200
+
201
+
202
+
203
+ <span class="summary_desc"><div class='inline'>
204
+ <p>Time#localtime with timezone (non-destructive).</p>
205
+ </div></span>
206
+
207
+ </li>
208
+
209
+
210
+ <li class="public ">
211
+ <span class="summary_signature">
212
+
213
+ <a href="#localtime_with_zone%21-class_method" title="localtime_with_zone! (class method)">+ (Object) <strong>localtime_with_zone!</strong>(time, timezone) </a>
214
+
215
+
216
+
217
+ </span>
218
+
219
+
220
+
221
+
222
+
223
+
224
+
225
+
226
+
227
+ <span class="summary_desc"><div class='inline'>
228
+ <p>Time#localtime with timezone (destructive).</p>
229
+ </div></span>
230
+
231
+ </li>
232
+
233
+
234
+ <li class="public ">
235
+ <span class="summary_signature">
236
+
237
+ <a href="#overwrite_zone-class_method" title="overwrite_zone (class method)">+ (Time) <strong>overwrite_zone</strong>(time, timezone) </a>
238
+
239
+
240
+
241
+ </span>
242
+
243
+
244
+
245
+
246
+
247
+
248
+
249
+
250
+
251
+ <span class="summary_desc"><div class='inline'>
252
+ <p>This method simply overwrites the zone field of Time object
253
+ (non-destructive).</p>
254
+ </div></span>
255
+
256
+ </li>
257
+
258
+
259
+ <li class="public ">
260
+ <span class="summary_signature">
261
+
262
+ <a href="#overwrite_zone%21-class_method" title="overwrite_zone! (class method)">+ (Object) <strong>overwrite_zone!</strong>(time, timezone) </a>
263
+
264
+
265
+
266
+ </span>
267
+
268
+
269
+
270
+
271
+
272
+
273
+
274
+
275
+
276
+ <span class="summary_desc"><div class='inline'>
277
+ <p>This method simply overwrites the zone field of Time object (destructive).</p>
278
+ </div></span>
279
+
280
+ </li>
281
+
282
+
283
+ <li class="public ">
284
+ <span class="summary_signature">
285
+
286
+ <a href="#parse_with_zone-class_method" title="parse_with_zone (class method)">+ (Object) <strong>parse_with_zone</strong>(date, timezone) </a>
287
+
288
+
289
+
290
+ </span>
291
+
292
+
293
+
294
+
295
+
296
+
297
+
298
+
299
+
300
+ <span class="summary_desc"><div class='inline'>
301
+ <p>Time.parse with timezone.</p>
302
+ </div></span>
303
+
304
+ </li>
305
+
306
+
307
+ <li class="public ">
308
+ <span class="summary_signature">
309
+
310
+ <a href="#strptime_with_zone-class_method" title="strptime_with_zone (class method)">+ (Object) <strong>strptime_with_zone</strong>(date, format, timezone) </a>
311
+
312
+
313
+
314
+ </span>
315
+
316
+
317
+
318
+
319
+
320
+
321
+
322
+
323
+
324
+ <span class="summary_desc"><div class='inline'>
325
+ <p>Time.strptime with timezone.</p>
326
+ </div></span>
327
+
328
+ </li>
329
+
330
+
331
+ <li class="public ">
332
+ <span class="summary_signature">
333
+
334
+ <a href="#zone_offset-class_method" title="zone_offset (class method)">+ (Integer) <strong>zone_offset</strong>(timezone, time = nil) </a>
335
+
336
+
337
+
338
+ </span>
339
+
340
+
341
+
342
+
343
+
344
+
345
+
346
+
347
+
348
+ <span class="summary_desc"><div class='inline'>
349
+ <p>Returns zone offset for given timezone string.</p>
350
+ </div></span>
351
+
352
+ </li>
353
+
354
+
355
+ </ul>
356
+
357
+
358
+
359
+
360
+ <div id="class_method_details" class="method_details_list">
361
+ <h2>Class Method Details</h2>
362
+
363
+
364
+ <div class="method_details first">
365
+ <h3 class="signature first" id="localtime_with_zone-class_method">
366
+
367
+ + (<tt>Object</tt>) <strong>localtime_with_zone</strong>(time, timezone)
368
+
369
+
370
+
371
+
372
+
373
+ </h3><div class="docstring">
374
+ <div class="discussion">
375
+
376
+ <p>Time#localtime with timezone (non-destructive)</p>
377
+
378
+ <pre class="code ruby"><code class="ruby"><span class='const'>ENV</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>TZ</span><span class='tstring_end'>&#39;</span></span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>+09:00</span><span class='tstring_end'>&#39;</span></span> <span class='comment'># Assume your local timezone is +09:00
379
+ </span>
380
+ <span class='id identifier rubyid_require'>require</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>time</span><span class='tstring_end'>&#39;</span></span>
381
+
382
+ <span class='id identifier rubyid_time'>time</span> <span class='op'>=</span> <span class='const'>Time</span><span class='period'>.</span><span class='id identifier rubyid_parse'>parse</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>2016-10-20 00:00:00 +00:00</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
383
+ <span class='id identifier rubyid_time'>time</span><span class='period'>.</span><span class='id identifier rubyid_dup'>dup</span><span class='period'>.</span><span class='id identifier rubyid_localtime'>localtime</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>+08:00</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
384
+ <span class='comment'>#=&gt; 2010-10-20 08:00:00 +0800
385
+ </span><span class='id identifier rubyid_time'>time</span><span class='period'>.</span><span class='id identifier rubyid_dump'>dump</span><span class='period'>.</span><span class='id identifier rubyid_localtime'>localtime</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>CDT</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
386
+ <span class='comment'>#=&gt; error
387
+ </span><span class='id identifier rubyid_time'>time</span><span class='period'>.</span><span class='id identifier rubyid_dump'>dump</span><span class='period'>.</span><span class='id identifier rubyid_localtime'>localtime</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Asia/Taipei</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
388
+ <span class='comment'>#=&gt; error
389
+ </span>
390
+ <span class='id identifier rubyid_require'>require</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>time_with_zone</span><span class='tstring_end'>&#39;</span></span>
391
+
392
+ <span class='id identifier rubyid_time'>time</span> <span class='op'>=</span> <span class='const'>Time</span><span class='period'>.</span><span class='id identifier rubyid_parse'>parse</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>2016-10-20 00:00:00 +00:00</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
393
+ <span class='const'>TimeWithZone</span><span class='period'>.</span><span class='id identifier rubyid_localtime_with_zone'>localtime_with_zone</span><span class='lparen'>(</span><span class='id identifier rubyid_time'>time</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>+08:00</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
394
+ <span class='comment'>#=&gt; 2010-10-20 08:00:00 +0800
395
+ </span><span class='const'>TimeWithZone</span><span class='period'>.</span><span class='id identifier rubyid_localtime_with_zone'>localtime_with_zone</span><span class='lparen'>(</span><span class='id identifier rubyid_time'>time</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>CDT</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
396
+ <span class='comment'>#=&gt; 2016-10-19 19:00:00 -0500
397
+ </span><span class='const'>TimeWithZone</span><span class='period'>.</span><span class='id identifier rubyid_localtime_with_zone'>localtime_with_zone</span><span class='lparen'>(</span><span class='id identifier rubyid_time'>time</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Asia/Taipei</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
398
+ <span class='comment'>#=&gt; 2010-10-20 08:00:00 +0800
399
+ </span></code></pre>
400
+
401
+
402
+ </div>
403
+ </div>
404
+ <div class="tags">
405
+ <p class="tag_title">Parameters:</p>
406
+ <ul class="param">
407
+
408
+ <li>
409
+
410
+ <span class='name'>time</span>
411
+
412
+
413
+ <span class='type'>(<tt>Time</tt>)</span>
414
+
415
+
416
+
417
+ &mdash;
418
+ <div class='inline'>
419
+ <p>object</p>
420
+ </div>
421
+
422
+ </li>
423
+
424
+ <li>
425
+
426
+ <span class='name'>timezone</span>
427
+
428
+
429
+ <span class='type'>(<tt>String</tt>)</span>
430
+
431
+
432
+
433
+ &mdash;
434
+ <div class='inline'>
435
+ <p><span class='object_link'><a href="#NUMERIC_PATTERN-constant" title="TimeWithZone::NUMERIC_PATTERN (constant)">NUMERIC_PATTERN</a></span> or <span class='object_link'><a href="#NAME_PATTERN-constant" title="TimeWithZone::NAME_PATTERN (constant)">NAME_PATTERN</a></span> or <span class='object_link'><a href="#ZoneOffset-constant" title="TimeWithZone::ZoneOffset (constant)">ZoneOffset</a></span></p>
436
+ </div>
437
+
438
+ </li>
439
+
440
+ <li>
441
+
442
+ <span class='name'></span>
443
+
444
+
445
+ <span class='type'>(<tt>Time</tt>)</span>
446
+
447
+
448
+
449
+ </li>
450
+
451
+ </ul>
452
+
453
+
454
+ </div><table class="source_code">
455
+ <tr>
456
+ <td>
457
+ <pre class="lines">
458
+
459
+
460
+ 44
461
+ 45
462
+ 46</pre>
463
+ </td>
464
+ <td>
465
+ <pre class="code"><span class="info file"># File 'lib/time_with_zone.rb', line 44</span>
466
+
467
+ <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_localtime_with_zone'>localtime_with_zone</span><span class='lparen'>(</span><span class='id identifier rubyid_time'>time</span><span class='comma'>,</span> <span class='id identifier rubyid_timezone'>timezone</span><span class='rparen'>)</span>
468
+ <span class='id identifier rubyid_localtime_with_zone!'>localtime_with_zone!</span><span class='lparen'>(</span><span class='id identifier rubyid_time'>time</span><span class='period'>.</span><span class='id identifier rubyid_dup'>dup</span><span class='comma'>,</span> <span class='id identifier rubyid_timezone'>timezone</span><span class='rparen'>)</span>
469
+ <span class='kw'>end</span></pre>
470
+ </td>
471
+ </tr>
472
+ </table>
473
+ </div>
474
+
475
+ <div class="method_details ">
476
+ <h3 class="signature " id="localtime_with_zone!-class_method">
477
+
478
+ + (<tt>Object</tt>) <strong>localtime_with_zone!</strong>(time, timezone)
479
+
480
+
481
+
482
+
483
+
484
+ </h3><div class="docstring">
485
+ <div class="discussion">
486
+
487
+ <p>Time#localtime with timezone (destructive)</p>
488
+
489
+
490
+ </div>
491
+ </div>
492
+ <div class="tags">
493
+ <p class="tag_title">Parameters:</p>
494
+ <ul class="param">
495
+
496
+ <li>
497
+
498
+ <span class='name'>time</span>
499
+
500
+
501
+ <span class='type'>(<tt>Time</tt>)</span>
502
+
503
+
504
+
505
+ &mdash;
506
+ <div class='inline'>
507
+ <p>object</p>
508
+ </div>
509
+
510
+ </li>
511
+
512
+ <li>
513
+
514
+ <span class='name'>timezone</span>
515
+
516
+
517
+ <span class='type'>(<tt>String</tt>)</span>
518
+
519
+
520
+
521
+ &mdash;
522
+ <div class='inline'>
523
+ <p><span class='object_link'><a href="#NUMERIC_PATTERN-constant" title="TimeWithZone::NUMERIC_PATTERN (constant)">NUMERIC_PATTERN</a></span> or <span class='object_link'><a href="#NAME_PATTERN-constant" title="TimeWithZone::NAME_PATTERN (constant)">NAME_PATTERN</a></span> or <span class='object_link'><a href="#ZoneOffset-constant" title="TimeWithZone::ZoneOffset (constant)">ZoneOffset</a></span></p>
524
+ </div>
525
+
526
+ </li>
527
+
528
+ </ul>
529
+
530
+
531
+ <p class="tag_title">See Also:</p>
532
+ <ul class="see">
533
+
534
+ <li><span class='object_link'><a href="#localtime_with_zone-class_method" title="TimeWithZone.localtime_with_zone (method)">localtime_with_zone</a></span></li>
535
+
536
+ </ul>
537
+
538
+ </div><table class="source_code">
539
+ <tr>
540
+ <td>
541
+ <pre class="lines">
542
+
543
+
544
+ 53
545
+ 54
546
+ 55
547
+ 56</pre>
548
+ </td>
549
+ <td>
550
+ <pre class="code"><span class="info file"># File 'lib/time_with_zone.rb', line 53</span>
551
+
552
+ <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_localtime_with_zone!'>localtime_with_zone!</span><span class='lparen'>(</span><span class='id identifier rubyid_time'>time</span><span class='comma'>,</span> <span class='id identifier rubyid_timezone'>timezone</span><span class='rparen'>)</span>
553
+ <span class='id identifier rubyid__zone_offset'>_zone_offset</span> <span class='op'>=</span> <span class='id identifier rubyid_zone_offset'>zone_offset</span><span class='lparen'>(</span><span class='id identifier rubyid_timezone'>timezone</span><span class='comma'>,</span> <span class='id identifier rubyid_time'>time</span><span class='rparen'>)</span>
554
+ <span class='id identifier rubyid_time'>time</span><span class='period'>.</span><span class='id identifier rubyid_localtime'>localtime</span><span class='lparen'>(</span><span class='id identifier rubyid__zone_offset'>_zone_offset</span><span class='rparen'>)</span>
555
+ <span class='kw'>end</span></pre>
556
+ </td>
557
+ </tr>
558
+ </table>
559
+ </div>
560
+
561
+ <div class="method_details ">
562
+ <h3 class="signature " id="overwrite_zone-class_method">
563
+
564
+ + (<tt>Time</tt>) <strong>overwrite_zone</strong>(time, timezone)
565
+
566
+
567
+
568
+
569
+
570
+ </h3><div class="docstring">
571
+ <div class="discussion">
572
+
573
+ <p>This method simply overwrites the zone field of Time object
574
+ (non-destructive)</p>
575
+
576
+ <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_require'>require</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>time_with_zone</span><span class='tstring_end'>&#39;</span></span>
577
+
578
+ <span class='const'>TimeWithZone</span><span class='period'>.</span><span class='id identifier rubyid_overwrite_zone!'>overwrite_zone!</span><span class='lparen'>(</span><span class='const'>Time</span><span class='period'>.</span><span class='id identifier rubyid_parse'>parse</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>2010-02-02 +09:00</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>+08:00</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
579
+ <span class='comment'>#=&gt; &quot;2010-02-02 00:00:00 +08:00&quot; (Note that not &quot;2010-02-01 23:00:00 +08:00&quot;)
580
+ </span></code></pre>
581
+
582
+
583
+ </div>
584
+ </div>
585
+ <div class="tags">
586
+ <p class="tag_title">Parameters:</p>
587
+ <ul class="param">
588
+
589
+ <li>
590
+
591
+ <span class='name'>time</span>
592
+
593
+
594
+ <span class='type'>(<tt>Time</tt>)</span>
595
+
596
+
597
+
598
+ </li>
599
+
600
+ <li>
601
+
602
+ <span class='name'>timezone</span>
603
+
604
+
605
+ <span class='type'>(<tt>String</tt>)</span>
606
+
607
+
608
+
609
+ </li>
610
+
611
+ </ul>
612
+
613
+ <p class="tag_title">Returns:</p>
614
+ <ul class="return">
615
+
616
+ <li>
617
+
618
+
619
+ <span class='type'>(<tt>Time</tt>)</span>
620
+
621
+
622
+
623
+ </li>
624
+
625
+ </ul>
626
+
627
+ </div><table class="source_code">
628
+ <tr>
629
+ <td>
630
+ <pre class="lines">
631
+
632
+
633
+ 131
634
+ 132
635
+ 133</pre>
636
+ </td>
637
+ <td>
638
+ <pre class="code"><span class="info file"># File 'lib/time_with_zone.rb', line 131</span>
639
+
640
+ <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_overwrite_zone'>overwrite_zone</span><span class='lparen'>(</span><span class='id identifier rubyid_time'>time</span><span class='comma'>,</span> <span class='id identifier rubyid_timezone'>timezone</span><span class='rparen'>)</span>
641
+ <span class='id identifier rubyid_overwrite_zone!'>overwrite_zone!</span><span class='lparen'>(</span><span class='id identifier rubyid_time'>time</span><span class='period'>.</span><span class='id identifier rubyid_dup'>dup</span><span class='comma'>,</span> <span class='id identifier rubyid_timezone'>timezone</span><span class='rparen'>)</span>
642
+ <span class='kw'>end</span></pre>
643
+ </td>
644
+ </tr>
645
+ </table>
646
+ </div>
647
+
648
+ <div class="method_details ">
649
+ <h3 class="signature " id="overwrite_zone!-class_method">
650
+
651
+ + (<tt>Object</tt>) <strong>overwrite_zone!</strong>(time, timezone)
652
+
653
+
654
+
655
+
656
+
657
+ </h3><div class="docstring">
658
+ <div class="discussion">
659
+
660
+ <p>This method simply overwrites the zone field of Time object (destructive)</p>
661
+
662
+
663
+ </div>
664
+ </div>
665
+ <div class="tags">
666
+ <p class="tag_title">Parameters:</p>
667
+ <ul class="param">
668
+
669
+ <li>
670
+
671
+ <span class='name'>time</span>
672
+
673
+
674
+ <span class='type'>(<tt>Time</tt>)</span>
675
+
676
+
677
+
678
+ </li>
679
+
680
+ <li>
681
+
682
+ <span class='name'>timezone</span>
683
+
684
+
685
+ <span class='type'>(<tt>String</tt>)</span>
686
+
687
+
688
+
689
+ </li>
690
+
691
+ </ul>
692
+
693
+
694
+ <p class="tag_title">See Also:</p>
695
+ <ul class="see">
696
+
697
+ <li><span class='object_link'><a href="#overwrite_zone-class_method" title="TimeWithZone.overwrite_zone (method)">overwrite_zone</a></span></li>
698
+
699
+ </ul>
700
+
701
+ </div><table class="source_code">
702
+ <tr>
703
+ <td>
704
+ <pre class="lines">
705
+
706
+
707
+ 140
708
+ 141
709
+ 142
710
+ 143
711
+ 144</pre>
712
+ </td>
713
+ <td>
714
+ <pre class="code"><span class="info file"># File 'lib/time_with_zone.rb', line 140</span>
715
+
716
+ <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_overwrite_zone!'>overwrite_zone!</span><span class='lparen'>(</span><span class='id identifier rubyid_time'>time</span><span class='comma'>,</span> <span class='id identifier rubyid_timezone'>timezone</span><span class='rparen'>)</span>
717
+ <span class='id identifier rubyid__utc_offset'>_utc_offset</span> <span class='op'>=</span> <span class='id identifier rubyid_time'>time</span><span class='period'>.</span><span class='id identifier rubyid_utc_offset'>utc_offset</span>
718
+ <span class='id identifier rubyid__zone_offset'>_zone_offset</span> <span class='op'>=</span> <span class='id identifier rubyid_zone_offset'>zone_offset</span><span class='lparen'>(</span><span class='id identifier rubyid_timezone'>timezone</span><span class='comma'>,</span> <span class='id identifier rubyid_time'>time</span><span class='rparen'>)</span>
719
+ <span class='id identifier rubyid_time'>time</span><span class='period'>.</span><span class='id identifier rubyid_localtime'>localtime</span><span class='lparen'>(</span><span class='id identifier rubyid__zone_offset'>_zone_offset</span><span class='rparen'>)</span> <span class='op'>+</span> <span class='id identifier rubyid__utc_offset'>_utc_offset</span> <span class='op'>-</span> <span class='id identifier rubyid__zone_offset'>_zone_offset</span>
720
+ <span class='kw'>end</span></pre>
721
+ </td>
722
+ </tr>
723
+ </table>
724
+ </div>
725
+
726
+ <div class="method_details ">
727
+ <h3 class="signature " id="parse_with_zone-class_method">
728
+
729
+ + (<tt>Object</tt>) <strong>parse_with_zone</strong>(date, timezone)
730
+
731
+
732
+
733
+
734
+
735
+ </h3><div class="docstring">
736
+ <div class="discussion">
737
+
738
+ <p>Time.parse with timezone</p>
739
+
740
+ <pre class="code ruby"><code class="ruby"><span class='const'>ENV</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>TZ</span><span class='tstring_end'>&#39;</span></span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>+09:00</span><span class='tstring_end'>&#39;</span></span> <span class='comment'># Assume your local timezone is +09:00
741
+ </span>
742
+ <span class='id identifier rubyid_require'>require</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>time</span><span class='tstring_end'>&#39;</span></span>
743
+
744
+ <span class='const'>Time</span><span class='period'>.</span><span class='id identifier rubyid_parse'>parse</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>2016-10-20</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
745
+ <span class='comment'>#=&gt; 2016-10-20 00:00:00 +0900
746
+ </span><span class='const'>Time</span><span class='period'>.</span><span class='id identifier rubyid_parse'>parse</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>2016-10-20 00:00:00 +08:00</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
747
+ <span class='comment'>#=&gt; 2016-10-20 00:00:00 +0800
748
+ </span><span class='const'>Time</span><span class='period'>.</span><span class='id identifier rubyid_parse'>parse</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>2016-10-20 00:00:00 CDT</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
749
+ <span class='comment'>#=&gt; 2016-10-20 00:00:00 -0500
750
+ </span><span class='const'>Time</span><span class='period'>.</span><span class='id identifier rubyid_parse'>parse</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>2016-10-20 00:00:00 Asia/Taipei</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
751
+ <span class='comment'>#=&gt; 2016-10-20 00:00:00 +0900 (does not work)
752
+ </span>
753
+ <span class='id identifier rubyid_require'>require</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>time_with_zone</span><span class='tstring_end'>&#39;</span></span>
754
+
755
+ <span class='const'>TimeWithZone</span><span class='period'>.</span><span class='id identifier rubyid_parse_with_zone'>parse_with_zone</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>2016-10-20</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>+08:00</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
756
+ <span class='comment'>#=&gt; 2016-10-20 00:00:00 +0800
757
+ </span><span class='const'>TimeWithZone</span><span class='period'>.</span><span class='id identifier rubyid_parse_with_zone'>parse_with_zone</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>2016-10-20</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>CDT</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
758
+ <span class='comment'>#=&gt; 2016-10-20 00:00:00 -0500
759
+ </span><span class='const'>TimeWithZone</span><span class='period'>.</span><span class='id identifier rubyid_parse_with_zone'>parse_with_zone</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>2016-10-20</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Asia/Taipei</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
760
+ <span class='comment'>#=&gt; 2016-10-20 00:00:00 +0800
761
+ </span></code></pre>
762
+
763
+
764
+ </div>
765
+ </div>
766
+ <div class="tags">
767
+ <p class="tag_title">Parameters:</p>
768
+ <ul class="param">
769
+
770
+ <li>
771
+
772
+ <span class='name'>date</span>
773
+
774
+
775
+ <span class='type'>(<tt>String</tt>)</span>
776
+
777
+
778
+
779
+ &mdash;
780
+ <div class='inline'>
781
+ <p>string to be parsed</p>
782
+ </div>
783
+
784
+ </li>
785
+
786
+ <li>
787
+
788
+ <span class='name'>timezone</span>
789
+
790
+
791
+ <span class='type'>(<tt>String</tt>)</span>
792
+
793
+
794
+
795
+ &mdash;
796
+ <div class='inline'>
797
+ <p><span class='object_link'><a href="#NUMERIC_PATTERN-constant" title="TimeWithZone::NUMERIC_PATTERN (constant)">NUMERIC_PATTERN</a></span> or <span class='object_link'><a href="#NAME_PATTERN-constant" title="TimeWithZone::NAME_PATTERN (constant)">NAME_PATTERN</a></span> or <span class='object_link'><a href="#ZoneOffset-constant" title="TimeWithZone::ZoneOffset (constant)">ZoneOffset</a></span></p>
798
+ </div>
799
+
800
+ </li>
801
+
802
+ </ul>
803
+
804
+
805
+ </div><table class="source_code">
806
+ <tr>
807
+ <td>
808
+ <pre class="lines">
809
+
810
+
811
+ 84
812
+ 85
813
+ 86
814
+ 87</pre>
815
+ </td>
816
+ <td>
817
+ <pre class="code"><span class="info file"># File 'lib/time_with_zone.rb', line 84</span>
818
+
819
+ <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_parse_with_zone'>parse_with_zone</span><span class='lparen'>(</span><span class='id identifier rubyid_date'>date</span><span class='comma'>,</span> <span class='id identifier rubyid_timezone'>timezone</span><span class='rparen'>)</span>
820
+ <span class='id identifier rubyid_time'>time</span> <span class='op'>=</span> <span class='const'>Time</span><span class='period'>.</span><span class='id identifier rubyid_parse'>parse</span><span class='lparen'>(</span><span class='id identifier rubyid_date'>date</span><span class='rparen'>)</span>
821
+ <span class='id identifier rubyid_overwrite_zone!'>overwrite_zone!</span><span class='lparen'>(</span><span class='id identifier rubyid_time'>time</span><span class='comma'>,</span> <span class='id identifier rubyid_timezone'>timezone</span><span class='rparen'>)</span>
822
+ <span class='kw'>end</span></pre>
823
+ </td>
824
+ </tr>
825
+ </table>
826
+ </div>
827
+
828
+ <div class="method_details ">
829
+ <h3 class="signature " id="strptime_with_zone-class_method">
830
+
831
+ + (<tt>Object</tt>) <strong>strptime_with_zone</strong>(date, format, timezone)
832
+
833
+
834
+
835
+
836
+
837
+ </h3><div class="docstring">
838
+ <div class="discussion">
839
+
840
+ <p>Time.strptime with timezone</p>
841
+
842
+ <pre class="code ruby"><code class="ruby"><span class='const'>ENV</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>TZ</span><span class='tstring_end'>&#39;</span></span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>+09:00</span><span class='tstring_end'>&#39;</span></span> <span class='comment'># Assume your local timezone is +09:00
843
+ </span>
844
+ <span class='id identifier rubyid_require'>require</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>time</span><span class='tstring_end'>&#39;</span></span>
845
+
846
+ <span class='const'>Time</span><span class='period'>.</span><span class='id identifier rubyid_strptime'>strptime</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>2016-10-20</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%Y-%m-%d</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
847
+ <span class='comment'>#=&gt; 2016-10-20 00:00:00 +0900
848
+ </span><span class='const'>Time</span><span class='period'>.</span><span class='id identifier rubyid_strptime'>strptime</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>2016-10-20 +08:00</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%Y-%m-%d %z</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
849
+ <span class='comment'>#=&gt; 2016-10-20 00:00:00 +0800
850
+ </span><span class='const'>Time</span><span class='period'>.</span><span class='id identifier rubyid_strptime'>strptime</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>2016-10-20 CDT</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%Y-%m-%d %Z</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
851
+ <span class='comment'>#=&gt; 2016-10-20 00:00:00 -0500
852
+ </span><span class='const'>Time</span><span class='period'>.</span><span class='id identifier rubyid_strptime'>strptime</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>2016-10-20 Asia/Taipei</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%Y-%m-%d %Z</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
853
+ <span class='comment'>#=&gt; 2016-10-20 00:00:00 +0900 (does not work)
854
+ </span>
855
+ <span class='id identifier rubyid_require'>require</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>time_with_zone</span><span class='tstring_end'>&#39;</span></span>
856
+
857
+ <span class='const'>TimeWithZone</span><span class='period'>.</span><span class='id identifier rubyid_strptime_with_zone'>strptime_with_zone</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>2016-10-20</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%Y-%m-%d</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>+08:00</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
858
+ <span class='comment'>#=&gt; 2016-10-20 00:00:00 +0800
859
+ </span><span class='const'>TimeWithZone</span><span class='period'>.</span><span class='id identifier rubyid_strptime_with_zone'>strptime_with_zone</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>2016-10-20</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%Y-%m-%d</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>CDT</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
860
+ <span class='comment'>#=&gt; 2016-10-20 00:00:00 -0500
861
+ </span><span class='const'>TimeWithZone</span><span class='period'>.</span><span class='id identifier rubyid_strptime_with_zone'>strptime_with_zone</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>2016-10-20</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>%Y-%m-%d</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Asia/Taipei</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
862
+ <span class='comment'>#=&gt; 2016-10-20 00:00:00 +0800
863
+ </span></code></pre>
864
+
865
+
866
+ </div>
867
+ </div>
868
+ <div class="tags">
869
+ <p class="tag_title">Parameters:</p>
870
+ <ul class="param">
871
+
872
+ <li>
873
+
874
+ <span class='name'>date</span>
875
+
876
+
877
+ <span class='type'>(<tt>String</tt>)</span>
878
+
879
+
880
+
881
+ &mdash;
882
+ <div class='inline'>
883
+ <p>string to be parsed</p>
884
+ </div>
885
+
886
+ </li>
887
+
888
+ <li>
889
+
890
+ <span class='name'>format</span>
891
+
892
+
893
+ <span class='type'>(<tt>String</tt>)</span>
894
+
895
+
896
+
897
+ </li>
898
+
899
+ <li>
900
+
901
+ <span class='name'>timezone</span>
902
+
903
+
904
+ <span class='type'>(<tt>String</tt>)</span>
905
+
906
+
907
+
908
+ &mdash;
909
+ <div class='inline'>
910
+ <p><span class='object_link'><a href="#NUMERIC_PATTERN-constant" title="TimeWithZone::NUMERIC_PATTERN (constant)">NUMERIC_PATTERN</a></span> or <span class='object_link'><a href="#NAME_PATTERN-constant" title="TimeWithZone::NAME_PATTERN (constant)">NAME_PATTERN</a></span> or <span class='object_link'><a href="#ZoneOffset-constant" title="TimeWithZone::ZoneOffset (constant)">ZoneOffset</a></span></p>
911
+ </div>
912
+
913
+ </li>
914
+
915
+ </ul>
916
+
917
+
918
+ </div><table class="source_code">
919
+ <tr>
920
+ <td>
921
+ <pre class="lines">
922
+
923
+
924
+ 116
925
+ 117
926
+ 118
927
+ 119</pre>
928
+ </td>
929
+ <td>
930
+ <pre class="code"><span class="info file"># File 'lib/time_with_zone.rb', line 116</span>
931
+
932
+ <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_strptime_with_zone'>strptime_with_zone</span><span class='lparen'>(</span><span class='id identifier rubyid_date'>date</span><span class='comma'>,</span> <span class='id identifier rubyid_format'>format</span><span class='comma'>,</span> <span class='id identifier rubyid_timezone'>timezone</span><span class='rparen'>)</span>
933
+ <span class='id identifier rubyid_time'>time</span> <span class='op'>=</span> <span class='const'>Time</span><span class='period'>.</span><span class='id identifier rubyid_strptime'>strptime</span><span class='lparen'>(</span><span class='id identifier rubyid_date'>date</span><span class='comma'>,</span> <span class='id identifier rubyid_format'>format</span><span class='rparen'>)</span>
934
+ <span class='id identifier rubyid_overwrite_zone!'>overwrite_zone!</span><span class='lparen'>(</span><span class='id identifier rubyid_time'>time</span><span class='comma'>,</span> <span class='id identifier rubyid_timezone'>timezone</span><span class='rparen'>)</span>
935
+ <span class='kw'>end</span></pre>
936
+ </td>
937
+ </tr>
938
+ </table>
939
+ </div>
940
+
941
+ <div class="method_details ">
942
+ <h3 class="signature " id="zone_offset-class_method">
943
+
944
+ + (<tt>Integer</tt>) <strong>zone_offset</strong>(timezone, time = nil)
945
+
946
+
947
+
948
+
949
+
950
+ </h3><div class="docstring">
951
+ <div class="discussion">
952
+
953
+ <p>Returns zone offset for given timezone string</p>
954
+
955
+ <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_require'>require</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>time_with_zone</span><span class='tstring_end'>&#39;</span></span>
956
+
957
+ <span class='const'>TimeWithZone</span><span class='period'>.</span><span class='id identifier rubyid_zone_offset'>zone_offset</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>+08:00</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
958
+ <span class='comment'>#=&gt; 28800
959
+ </span><span class='const'>TimeWithZone</span><span class='period'>.</span><span class='id identifier rubyid_zone_offset'>zone_offset</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Asia/Taipei</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
960
+ <span class='comment'>#=&gt; 28800
961
+ </span><span class='const'>TimeWithZone</span><span class='period'>.</span><span class='id identifier rubyid_zone_offset'>zone_offset</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>PST</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
962
+ <span class='comment'>#=&gt; -28800
963
+ </span><span class='const'>TimeWithZone</span><span class='period'>.</span><span class='id identifier rubyid_zone_offset'>zone_offset</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>America/Los_Angeles</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
964
+ <span class='comment'>#=&gt; -25200
965
+ </span><span class='const'>TimeWithZone</span><span class='period'>.</span><span class='id identifier rubyid_zone_offset'>zone_offset</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>America/Los_Angeles</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='const'>Time</span><span class='period'>.</span><span class='id identifier rubyid_parse'>parse</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>2016-07-07 00:00:00 +00:00</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span><span class='rparen'>)</span>
966
+ <span class='comment'>#=&gt; -25200 # DST (Daylight Saving Time)
967
+ </span><span class='const'>TimeWithZone</span><span class='period'>.</span><span class='id identifier rubyid_zone_offset'>zone_offset</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>America/Los_Angeles</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='const'>Time</span><span class='period'>.</span><span class='id identifier rubyid_parse'>parse</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>2016-01-01 00:00:00 +00:00</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span><span class='rparen'>)</span>
968
+ <span class='comment'>#=&gt; -28800 # non DST
969
+ </span></code></pre>
970
+
971
+
972
+ </div>
973
+ </div>
974
+ <div class="tags">
975
+ <p class="tag_title">Parameters:</p>
976
+ <ul class="param">
977
+
978
+ <li>
979
+
980
+ <span class='name'>timezone</span>
981
+
982
+
983
+ <span class='type'>(<tt>String</tt>)</span>
984
+
985
+
986
+
987
+ &mdash;
988
+ <div class='inline'>
989
+ <p><span class='object_link'><a href="#NUMERIC_PATTERN-constant" title="TimeWithZone::NUMERIC_PATTERN (constant)">NUMERIC_PATTERN</a></span> or <span class='object_link'><a href="#NAME_PATTERN-constant" title="TimeWithZone::NAME_PATTERN (constant)">NAME_PATTERN</a></span> or <span class='object_link'><a href="#ZoneOffset-constant" title="TimeWithZone::ZoneOffset (constant)">ZoneOffset</a></span></p>
990
+ </div>
991
+
992
+ </li>
993
+
994
+ <li>
995
+
996
+ <span class='name'>time</span>
997
+
998
+
999
+ <span class='type'>(<tt>Time</tt>)</span>
1000
+
1001
+
1002
+ <em class="default">(defaults to: <tt>nil</tt>)</em>
1003
+
1004
+
1005
+ &mdash;
1006
+ <div class='inline'>
1007
+ <p>if you need to consider Daylight Saving Time</p>
1008
+ </div>
1009
+
1010
+ </li>
1011
+
1012
+ </ul>
1013
+
1014
+ <p class="tag_title">Returns:</p>
1015
+ <ul class="return">
1016
+
1017
+ <li>
1018
+
1019
+
1020
+ <span class='type'>(<tt>Integer</tt>)</span>
1021
+
1022
+
1023
+
1024
+ &mdash;
1025
+ <div class='inline'>
1026
+ <p>zone offset</p>
1027
+ </div>
1028
+
1029
+ </li>
1030
+
1031
+ </ul>
1032
+
1033
+ </div><table class="source_code">
1034
+ <tr>
1035
+ <td>
1036
+ <pre class="lines">
1037
+
1038
+
1039
+ 166
1040
+ 167
1041
+ 168
1042
+ 169
1043
+ 170
1044
+ 171
1045
+ 172
1046
+ 173
1047
+ 174
1048
+ 175
1049
+ 176
1050
+ 177
1051
+ 178
1052
+ 179
1053
+ 180
1054
+ 181</pre>
1055
+ </td>
1056
+ <td>
1057
+ <pre class="code"><span class="info file"># File 'lib/time_with_zone.rb', line 166</span>
1058
+
1059
+ <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_zone_offset'>zone_offset</span><span class='lparen'>(</span><span class='id identifier rubyid_timezone'>timezone</span><span class='comma'>,</span> <span class='id identifier rubyid_time'>time</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='rparen'>)</span>
1060
+ <span class='kw'>if</span> <span class='const'>NUMERIC_PATTERN</span> <span class='op'>===</span> <span class='id identifier rubyid_timezone'>timezone</span>
1061
+ <span class='const'>Time</span><span class='period'>.</span><span class='id identifier rubyid_zone_offset'>zone_offset</span><span class='lparen'>(</span><span class='id identifier rubyid_timezone'>timezone</span><span class='rparen'>)</span>
1062
+ <span class='kw'>elsif</span> <span class='const'>NAME_PATTERN</span> <span class='op'>===</span> <span class='id identifier rubyid_timezone'>timezone</span>
1063
+ <span class='id identifier rubyid_tz'>tz</span> <span class='op'>=</span> <span class='const'>TZInfo</span><span class='op'>::</span><span class='const'>Timezone</span><span class='period'>.</span><span class='id identifier rubyid_get'>get</span><span class='lparen'>(</span><span class='id identifier rubyid_timezone'>timezone</span><span class='rparen'>)</span>
1064
+ <span class='kw'>if</span> <span class='id identifier rubyid_time'>time</span>
1065
+ <span class='id identifier rubyid_tz'>tz</span><span class='period'>.</span><span class='id identifier rubyid_period_for_utc'>period_for_utc</span><span class='lparen'>(</span><span class='id identifier rubyid_time'>time</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_utc_total_offset'>utc_total_offset</span>
1066
+ <span class='kw'>else</span>
1067
+ <span class='id identifier rubyid_tz'>tz</span><span class='period'>.</span><span class='id identifier rubyid_current_period'>current_period</span><span class='period'>.</span><span class='id identifier rubyid_utc_total_offset'>utc_total_offset</span>
1068
+ <span class='kw'>end</span>
1069
+ <span class='kw'>elsif</span> <span class='const'>ZoneOffset</span><span class='period'>.</span><span class='id identifier rubyid_include?'>include?</span><span class='lparen'>(</span><span class='id identifier rubyid_timezone'>timezone</span><span class='rparen'>)</span>
1070
+ <span class='const'>ZoneOffset</span><span class='lbracket'>[</span><span class='id identifier rubyid_timezone'>timezone</span><span class='rbracket'>]</span> <span class='op'>*</span> <span class='int'>3600</span>
1071
+ <span class='kw'>else</span>
1072
+ <span class='id identifier rubyid_raise'>raise</span> <span class='const'>ArgumentError</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>timezone format is invalid: </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_timezone'>timezone</span><span class='embexpr_end'>}</span><span class='tstring_end'>&quot;</span></span>
1073
+ <span class='kw'>end</span>
1074
+ <span class='kw'>end</span></pre>
1075
+ </td>
1076
+ </tr>
1077
+ </table>
1078
+ </div>
1079
+
1080
+ </div>
1081
+
1082
+ </div>
1083
+
1084
+ <div id="footer">
1085
+ Generated on Sun Oct 30 22:45:52 2016 by
1086
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
1087
+ 0.8.7.6 (ruby-2.3.0).
1088
+ </div>
1089
+
1090
+ </body>
1091
+ </html>