lazier 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +6 -0
- data/.travis.yml +8 -0
- data/.yardopts +1 -0
- data/Gemfile +9 -0
- data/Gemfile.lock +82 -0
- data/README.md +33 -0
- data/Rakefile +18 -0
- data/doc/Lazier.html +557 -0
- data/doc/Lazier/Boolean.html +297 -0
- data/doc/Lazier/DateTime.html +787 -0
- data/doc/Lazier/DateTime/ClassMethods.html +1592 -0
- data/doc/Lazier/Exceptions.html +125 -0
- data/doc/Lazier/Exceptions/Dump.html +133 -0
- data/doc/Lazier/Hash.html +393 -0
- data/doc/Lazier/Math.html +130 -0
- data/doc/Lazier/Math/ClassMethods.html +362 -0
- data/doc/Lazier/Object.html +1565 -0
- data/doc/Lazier/Pathname.html +225 -0
- data/doc/Lazier/Settings.html +1249 -0
- data/doc/Lazier/String.html +471 -0
- data/doc/Lazier/TimeZone.html +1675 -0
- data/doc/Lazier/TimeZone/ClassMethods.html +1055 -0
- data/doc/Lazier/Version.html +189 -0
- data/doc/_index.html +306 -0
- data/doc/class_list.html +53 -0
- data/doc/css/common.css +1 -0
- data/doc/css/full_list.css +57 -0
- data/doc/css/style.css +328 -0
- data/doc/file.README.html +107 -0
- data/doc/file_list.html +55 -0
- data/doc/frames.html +28 -0
- data/doc/index.html +107 -0
- data/doc/js/app.js +214 -0
- data/doc/js/full_list.js +173 -0
- data/doc/js/jquery.js +4 -0
- data/doc/method_list.html +652 -0
- data/doc/top-level-namespace.html +112 -0
- data/lazier.gemspec +36 -0
- data/lib/lazier.rb +127 -0
- data/lib/lazier/boolean.rb +26 -0
- data/lib/lazier/datetime.rb +548 -0
- data/lib/lazier/exceptions.rb +14 -0
- data/lib/lazier/hash.rb +40 -0
- data/lib/lazier/math.rb +47 -0
- data/lib/lazier/object.rb +163 -0
- data/lib/lazier/pathname.rb +26 -0
- data/lib/lazier/settings.rb +118 -0
- data/lib/lazier/string.rb +54 -0
- data/lib/lazier/version.rb +24 -0
- data/spec/coverage_helper.rb +19 -0
- data/spec/cowtech-extensions/boolean_spec.rb +30 -0
- data/spec/cowtech-extensions/datetime_spec.rb +352 -0
- data/spec/cowtech-extensions/hash_spec.rb +30 -0
- data/spec/cowtech-extensions/math_spec.rb +41 -0
- data/spec/cowtech-extensions/object_spec.rb +231 -0
- data/spec/cowtech-extensions/pathname_spec.rb +21 -0
- data/spec/cowtech-extensions/settings_spec.rb +118 -0
- data/spec/cowtech-extensions/string_spec.rb +45 -0
- data/spec/lazier_spec.rb +57 -0
- data/spec/spec_helper.rb +16 -0
- metadata +292 -0
@@ -0,0 +1,1055 @@
|
|
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
|
+
Module: Lazier::TimeZone::ClassMethods
|
8
|
+
|
9
|
+
— Documentation by YARD 0.8.2.1
|
10
|
+
|
11
|
+
</title>
|
12
|
+
|
13
|
+
<link rel="stylesheet" href="../../css/style.css" type="text/css" media="screen" charset="utf-8" />
|
14
|
+
|
15
|
+
<link rel="stylesheet" href="../../css/common.css" type="text/css" media="screen" 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#!" + escape(window.location.href);
|
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 (C)</a> »
|
35
|
+
<span class='title'><span class='object_link'><a href="../../Lazier.html" title="Lazier (module)">Lazier</a></span></span> » <span class='title'><span class='object_link'><a href="../TimeZone.html" title="Lazier::TimeZone (module)">TimeZone</a></span></span>
|
36
|
+
»
|
37
|
+
<span class="title">ClassMethods</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>Module: Lazier::TimeZone::ClassMethods
|
67
|
+
|
68
|
+
|
69
|
+
|
70
|
+
</h1>
|
71
|
+
|
72
|
+
<dl class="box">
|
73
|
+
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
|
80
|
+
|
81
|
+
<dt class="r1 last">Defined in:</dt>
|
82
|
+
<dd class="r1 last">lib/lazier/datetime.rb</dd>
|
83
|
+
|
84
|
+
</dl>
|
85
|
+
<div class="clear"></div>
|
86
|
+
|
87
|
+
<h2>Overview</h2><div class="docstring">
|
88
|
+
<div class="discussion">
|
89
|
+
<p>General methods.</p>
|
90
|
+
|
91
|
+
|
92
|
+
</div>
|
93
|
+
</div>
|
94
|
+
<div class="tags">
|
95
|
+
|
96
|
+
|
97
|
+
</div>
|
98
|
+
|
99
|
+
|
100
|
+
|
101
|
+
|
102
|
+
|
103
|
+
|
104
|
+
|
105
|
+
<h2>
|
106
|
+
Instance Method Summary
|
107
|
+
<small>(<a href="#" class="summary_toggle">collapse</a>)</small>
|
108
|
+
</h2>
|
109
|
+
|
110
|
+
<ul class="summary">
|
111
|
+
|
112
|
+
<li class="public ">
|
113
|
+
<span class="summary_signature">
|
114
|
+
|
115
|
+
<a href="#compare-instance_method" title="#compare (instance method)">- (Fixnum) <strong>compare</strong>(left, right) </a>
|
116
|
+
|
117
|
+
|
118
|
+
|
119
|
+
</span>
|
120
|
+
|
121
|
+
|
122
|
+
|
123
|
+
|
124
|
+
|
125
|
+
|
126
|
+
|
127
|
+
|
128
|
+
|
129
|
+
<span class="summary_desc"><div class='inline'><p>Compares two timezones.</p>
|
130
|
+
</div></span>
|
131
|
+
|
132
|
+
</li>
|
133
|
+
|
134
|
+
|
135
|
+
<li class="public ">
|
136
|
+
<span class="summary_signature">
|
137
|
+
|
138
|
+
<a href="#find-instance_method" title="#find (instance method)">- (TimeZone) <strong>find</strong>(name, dst_label = nil) </a>
|
139
|
+
|
140
|
+
|
141
|
+
|
142
|
+
</span>
|
143
|
+
|
144
|
+
|
145
|
+
|
146
|
+
|
147
|
+
|
148
|
+
|
149
|
+
|
150
|
+
|
151
|
+
|
152
|
+
<span class="summary_desc"><div class='inline'><p>Find a zone by its name.</p>
|
153
|
+
</div></span>
|
154
|
+
|
155
|
+
</li>
|
156
|
+
|
157
|
+
|
158
|
+
<li class="public ">
|
159
|
+
<span class="summary_signature">
|
160
|
+
|
161
|
+
<a href="#format_offset-instance_method" title="#format_offset (instance method)">- (String) <strong>format_offset</strong>(offset, colon = true) </a>
|
162
|
+
|
163
|
+
|
164
|
+
|
165
|
+
</span>
|
166
|
+
|
167
|
+
|
168
|
+
|
169
|
+
|
170
|
+
|
171
|
+
|
172
|
+
|
173
|
+
|
174
|
+
|
175
|
+
<span class="summary_desc"><div class='inline'><p>Returns a +HH:MM formatted representation of the offset.</p>
|
176
|
+
</div></span>
|
177
|
+
|
178
|
+
</li>
|
179
|
+
|
180
|
+
|
181
|
+
<li class="public ">
|
182
|
+
<span class="summary_signature">
|
183
|
+
|
184
|
+
<a href="#list_all-instance_method" title="#list_all (instance method)">- (Array) <strong>list_all</strong>(with_dst = true, dst_label = nil) </a>
|
185
|
+
|
186
|
+
|
187
|
+
|
188
|
+
</span>
|
189
|
+
|
190
|
+
|
191
|
+
|
192
|
+
|
193
|
+
|
194
|
+
|
195
|
+
|
196
|
+
|
197
|
+
|
198
|
+
<span class="summary_desc"><div class='inline'><p>Returns a list of names of all timezones.</p>
|
199
|
+
</div></span>
|
200
|
+
|
201
|
+
</li>
|
202
|
+
|
203
|
+
|
204
|
+
<li class="public ">
|
205
|
+
<span class="summary_signature">
|
206
|
+
|
207
|
+
<a href="#parameterize_zone-instance_method" title="#parameterize_zone (instance method)">- (String) <strong>parameterize_zone</strong>(tz, with_offset = true) </a>
|
208
|
+
|
209
|
+
|
210
|
+
|
211
|
+
</span>
|
212
|
+
|
213
|
+
|
214
|
+
|
215
|
+
|
216
|
+
|
217
|
+
|
218
|
+
|
219
|
+
|
220
|
+
|
221
|
+
<span class="summary_desc"><div class='inline'><p>Returns a string representation of a timezone.</p>
|
222
|
+
</div></span>
|
223
|
+
|
224
|
+
</li>
|
225
|
+
|
226
|
+
|
227
|
+
<li class="public ">
|
228
|
+
<span class="summary_signature">
|
229
|
+
|
230
|
+
<a href="#rationalize_offset-instance_method" title="#rationalize_offset (instance method)">- (Rational) <strong>rationalize_offset</strong>(offset) </a>
|
231
|
+
|
232
|
+
|
233
|
+
|
234
|
+
</span>
|
235
|
+
|
236
|
+
|
237
|
+
|
238
|
+
|
239
|
+
|
240
|
+
|
241
|
+
|
242
|
+
|
243
|
+
|
244
|
+
<span class="summary_desc"><div class='inline'><p>Returns an offset in rational value.</p>
|
245
|
+
</div></span>
|
246
|
+
|
247
|
+
</li>
|
248
|
+
|
249
|
+
|
250
|
+
<li class="public ">
|
251
|
+
<span class="summary_signature">
|
252
|
+
|
253
|
+
<a href="#unparameterize_zone-instance_method" title="#unparameterize_zone (instance method)">- (String|TimeZone) <strong>unparameterize_zone</strong>(tz, as_string = false, dst_label = nil) </a>
|
254
|
+
|
255
|
+
|
256
|
+
|
257
|
+
</span>
|
258
|
+
|
259
|
+
|
260
|
+
|
261
|
+
|
262
|
+
|
263
|
+
|
264
|
+
|
265
|
+
|
266
|
+
|
267
|
+
<span class="summary_desc"><div class='inline'><p>Finds a parameterized timezone.</p>
|
268
|
+
</div></span>
|
269
|
+
|
270
|
+
</li>
|
271
|
+
|
272
|
+
|
273
|
+
</ul>
|
274
|
+
|
275
|
+
|
276
|
+
|
277
|
+
|
278
|
+
<div id="instance_method_details" class="method_details_list">
|
279
|
+
<h2>Instance Method Details</h2>
|
280
|
+
|
281
|
+
|
282
|
+
<div class="method_details first">
|
283
|
+
<h3 class="signature first" id="compare-instance_method">
|
284
|
+
|
285
|
+
- (<tt>Fixnum</tt>) <strong>compare</strong>(left, right)
|
286
|
+
|
287
|
+
|
288
|
+
|
289
|
+
|
290
|
+
|
291
|
+
</h3><div class="docstring">
|
292
|
+
<div class="discussion">
|
293
|
+
<p>Compares two timezones. They are sorted by the location name.</p>
|
294
|
+
|
295
|
+
|
296
|
+
</div>
|
297
|
+
</div>
|
298
|
+
<div class="tags">
|
299
|
+
<p class="tag_title">Parameters:</p>
|
300
|
+
<ul class="param">
|
301
|
+
|
302
|
+
<li>
|
303
|
+
|
304
|
+
<span class='name'>left</span>
|
305
|
+
|
306
|
+
|
307
|
+
<span class='type'>(<tt><span class='object_link'><a href="../String.html" title="Lazier::String (module)">String</a></span>|<span class='object_link'><a href="../TimeZone.html" title="Lazier::TimeZone (module)">TimeZone</a></span></tt>)</span>
|
308
|
+
|
309
|
+
|
310
|
+
|
311
|
+
—
|
312
|
+
<div class='inline'><p>The first zone name to compare.</p>
|
313
|
+
</div>
|
314
|
+
|
315
|
+
</li>
|
316
|
+
|
317
|
+
<li>
|
318
|
+
|
319
|
+
<span class='name'>right</span>
|
320
|
+
|
321
|
+
|
322
|
+
<span class='type'>(<tt><span class='object_link'><a href="../String.html" title="Lazier::String (module)">String</a></span>|<span class='object_link'><a href="../TimeZone.html" title="Lazier::TimeZone (module)">TimeZone</a></span></tt>)</span>
|
323
|
+
|
324
|
+
|
325
|
+
|
326
|
+
—
|
327
|
+
<div class='inline'><p>The second zone name to compare.</p>
|
328
|
+
</div>
|
329
|
+
|
330
|
+
</li>
|
331
|
+
|
332
|
+
</ul>
|
333
|
+
|
334
|
+
<p class="tag_title">Returns:</p>
|
335
|
+
<ul class="return">
|
336
|
+
|
337
|
+
<li>
|
338
|
+
|
339
|
+
|
340
|
+
<span class='type'>(<tt>Fixnum</tt>)</span>
|
341
|
+
|
342
|
+
|
343
|
+
|
344
|
+
—
|
345
|
+
<div class='inline'><p>The result of comparison, like Ruby's operator <code><=></code>.</p>
|
346
|
+
</div>
|
347
|
+
|
348
|
+
</li>
|
349
|
+
|
350
|
+
</ul>
|
351
|
+
|
352
|
+
</div><table class="source_code">
|
353
|
+
<tr>
|
354
|
+
<td>
|
355
|
+
<pre class="lines">
|
356
|
+
|
357
|
+
|
358
|
+
377
|
359
|
+
378
|
360
|
+
379
|
361
|
+
380
|
362
|
+
381</pre>
|
363
|
+
</td>
|
364
|
+
<td>
|
365
|
+
<pre class="code"><span class="info file"># File 'lib/lazier/datetime.rb', line 377</span>
|
366
|
+
|
367
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_compare'>compare</span><span class='lparen'>(</span><span class='id identifier rubyid_left'>left</span><span class='comma'>,</span> <span class='id identifier rubyid_right'>right</span><span class='rparen'>)</span>
|
368
|
+
<span class='id identifier rubyid_left'>left</span> <span class='op'>=</span> <span class='id identifier rubyid_left'>left</span><span class='period'>.</span><span class='id identifier rubyid_to_str'>to_str</span> <span class='kw'>if</span> <span class='id identifier rubyid_left'>left</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='op'>::</span><span class='const'>ActiveSupport</span><span class='op'>::</span><span class='const'>TimeZone</span><span class='rparen'>)</span>
|
369
|
+
<span class='id identifier rubyid_right'>right</span> <span class='op'>=</span> <span class='id identifier rubyid_right'>right</span><span class='period'>.</span><span class='id identifier rubyid_to_str'>to_str</span> <span class='kw'>if</span> <span class='id identifier rubyid_right'>right</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='op'>::</span><span class='const'>ActiveSupport</span><span class='op'>::</span><span class='const'>TimeZone</span><span class='rparen'>)</span>
|
370
|
+
<span class='id identifier rubyid_left'>left</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span><span class='period'>.</span><span class='id identifier rubyid_split'>split</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'> </span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='int'>2</span><span class='rparen'>)</span><span class='lbracket'>[</span><span class='int'>1</span><span class='rbracket'>]</span> <span class='op'><=></span> <span class='id identifier rubyid_right'>right</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span><span class='period'>.</span><span class='id identifier rubyid_split'>split</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'> </span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='int'>2</span><span class='rparen'>)</span><span class='lbracket'>[</span><span class='int'>1</span><span class='rbracket'>]</span>
|
371
|
+
<span class='kw'>end</span></pre>
|
372
|
+
</td>
|
373
|
+
</tr>
|
374
|
+
</table>
|
375
|
+
</div>
|
376
|
+
|
377
|
+
<div class="method_details ">
|
378
|
+
<h3 class="signature " id="find-instance_method">
|
379
|
+
|
380
|
+
- (<tt><span class='object_link'><a href="../TimeZone.html" title="Lazier::TimeZone (module)">TimeZone</a></span></tt>) <strong>find</strong>(name, dst_label = nil)
|
381
|
+
|
382
|
+
|
383
|
+
|
384
|
+
|
385
|
+
|
386
|
+
</h3><div class="docstring">
|
387
|
+
<div class="discussion">
|
388
|
+
<p>Find a zone by its name.</p>
|
389
|
+
|
390
|
+
|
391
|
+
</div>
|
392
|
+
</div>
|
393
|
+
<div class="tags">
|
394
|
+
<p class="tag_title">Parameters:</p>
|
395
|
+
<ul class="param">
|
396
|
+
|
397
|
+
<li>
|
398
|
+
|
399
|
+
<span class='name'>name</span>
|
400
|
+
|
401
|
+
|
402
|
+
<span class='type'>(<tt><span class='object_link'><a href="../String.html" title="Lazier::String (module)">String</a></span></tt>)</span>
|
403
|
+
|
404
|
+
|
405
|
+
|
406
|
+
—
|
407
|
+
<div class='inline'><p>The zone name.</p>
|
408
|
+
</div>
|
409
|
+
|
410
|
+
</li>
|
411
|
+
|
412
|
+
<li>
|
413
|
+
|
414
|
+
<span class='name'>dst_label</span>
|
415
|
+
|
416
|
+
|
417
|
+
<span class='type'>(<tt><span class='object_link'><a href="../String.html" title="Lazier::String (module)">String</a></span></tt>)</span>
|
418
|
+
|
419
|
+
|
420
|
+
<em class="default">(defaults to: <tt>nil</tt>)</em>
|
421
|
+
|
422
|
+
|
423
|
+
—
|
424
|
+
<div class='inline'><p>Label for the DST indication. Defaults to <code>(DST)</code>.</p>
|
425
|
+
</div>
|
426
|
+
|
427
|
+
</li>
|
428
|
+
|
429
|
+
</ul>
|
430
|
+
|
431
|
+
<p class="tag_title">Returns:</p>
|
432
|
+
<ul class="return">
|
433
|
+
|
434
|
+
<li>
|
435
|
+
|
436
|
+
|
437
|
+
<span class='type'>(<tt><span class='object_link'><a href="../TimeZone.html" title="Lazier::TimeZone (module)">TimeZone</a></span></tt>)</span>
|
438
|
+
|
439
|
+
|
440
|
+
|
441
|
+
—
|
442
|
+
<div class='inline'><p>A timezone or <code>nil</code> if no zone was found.</p>
|
443
|
+
</div>
|
444
|
+
|
445
|
+
</li>
|
446
|
+
|
447
|
+
</ul>
|
448
|
+
|
449
|
+
</div><table class="source_code">
|
450
|
+
<tr>
|
451
|
+
<td>
|
452
|
+
<pre class="lines">
|
453
|
+
|
454
|
+
|
455
|
+
289
|
456
|
+
290
|
457
|
+
291
|
458
|
+
292
|
459
|
+
293
|
460
|
+
294
|
461
|
+
295
|
462
|
+
296
|
463
|
+
297
|
464
|
+
298
|
465
|
+
299</pre>
|
466
|
+
</td>
|
467
|
+
<td>
|
468
|
+
<pre class="code"><span class="info file"># File 'lib/lazier/datetime.rb', line 289</span>
|
469
|
+
|
470
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_find'>find</span><span class='lparen'>(</span><span class='id identifier rubyid_name'>name</span><span class='comma'>,</span> <span class='id identifier rubyid_dst_label'>dst_label</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='rparen'>)</span>
|
471
|
+
<span class='id identifier rubyid_catch'>catch</span><span class='lparen'>(</span><span class='symbol'>:zone</span><span class='rparen'>)</span> <span class='kw'>do</span>
|
472
|
+
<span class='op'>::</span><span class='const'>ActiveSupport</span><span class='op'>::</span><span class='const'>TimeZone</span><span class='period'>.</span><span class='id identifier rubyid_all'>all</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_zone'>zone</span><span class='op'>|</span>
|
473
|
+
<span class='id identifier rubyid_zone'>zone</span><span class='period'>.</span><span class='id identifier rubyid_aliases'>aliases</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_zone_alias'>zone_alias</span><span class='op'>|</span>
|
474
|
+
<span class='id identifier rubyid_throw'>throw</span><span class='lparen'>(</span><span class='symbol'>:zone</span><span class='comma'>,</span> <span class='id identifier rubyid_zone'>zone</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='lbracket'>[</span><span class='id identifier rubyid_zone'>zone</span><span class='period'>.</span><span class='id identifier rubyid_to_str'>to_str</span><span class='lparen'>(</span><span class='id identifier rubyid_zone_alias'>zone_alias</span><span class='rparen'>)</span><span class='comma'>,</span> <span class='id identifier rubyid_zone'>zone</span><span class='period'>.</span><span class='id identifier rubyid_to_str_with_dst'>to_str_with_dst</span><span class='lparen'>(</span><span class='id identifier rubyid_dst_label'>dst_label</span><span class='comma'>,</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='id identifier rubyid_zone_alias'>zone_alias</span><span class='rparen'>)</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_include?'>include?</span><span class='lparen'>(</span><span class='id identifier rubyid_name'>name</span><span class='rparen'>)</span>
|
475
|
+
<span class='kw'>end</span>
|
476
|
+
<span class='kw'>end</span>
|
477
|
+
|
478
|
+
<span class='kw'>nil</span>
|
479
|
+
<span class='kw'>end</span>
|
480
|
+
<span class='kw'>end</span></pre>
|
481
|
+
</td>
|
482
|
+
</tr>
|
483
|
+
</table>
|
484
|
+
</div>
|
485
|
+
|
486
|
+
<div class="method_details ">
|
487
|
+
<h3 class="signature " id="format_offset-instance_method">
|
488
|
+
|
489
|
+
- (<tt><span class='object_link'><a href="../String.html" title="Lazier::String (module)">String</a></span></tt>) <strong>format_offset</strong>(offset, colon = true)
|
490
|
+
|
491
|
+
|
492
|
+
|
493
|
+
|
494
|
+
|
495
|
+
</h3><div class="docstring">
|
496
|
+
<div class="discussion">
|
497
|
+
<p>Returns a +HH:MM formatted representation of the offset.</p>
|
498
|
+
|
499
|
+
|
500
|
+
</div>
|
501
|
+
</div>
|
502
|
+
<div class="tags">
|
503
|
+
<p class="tag_title">Parameters:</p>
|
504
|
+
<ul class="param">
|
505
|
+
|
506
|
+
<li>
|
507
|
+
|
508
|
+
<span class='name'>offset</span>
|
509
|
+
|
510
|
+
|
511
|
+
<span class='type'>(<tt>Rational|Fixnum</tt>)</span>
|
512
|
+
|
513
|
+
|
514
|
+
|
515
|
+
—
|
516
|
+
<div class='inline'><p>The offset to represent, in seconds or as a rational.</p>
|
517
|
+
</div>
|
518
|
+
|
519
|
+
</li>
|
520
|
+
|
521
|
+
<li>
|
522
|
+
|
523
|
+
<span class='name'>colon</span>
|
524
|
+
|
525
|
+
|
526
|
+
<span class='type'>(<tt><span class='object_link'><a href="../Boolean.html" title="Lazier::Boolean (module)">Boolean</a></span></tt>)</span>
|
527
|
+
|
528
|
+
|
529
|
+
<em class="default">(defaults to: <tt>true</tt>)</em>
|
530
|
+
|
531
|
+
|
532
|
+
—
|
533
|
+
<div class='inline'><p>If to put the colon in the output string.</p>
|
534
|
+
</div>
|
535
|
+
|
536
|
+
</li>
|
537
|
+
|
538
|
+
</ul>
|
539
|
+
|
540
|
+
<p class="tag_title">Returns:</p>
|
541
|
+
<ul class="return">
|
542
|
+
|
543
|
+
<li>
|
544
|
+
|
545
|
+
|
546
|
+
<span class='type'>(<tt><span class='object_link'><a href="../String.html" title="Lazier::String (module)">String</a></span></tt>)</span>
|
547
|
+
|
548
|
+
|
549
|
+
|
550
|
+
—
|
551
|
+
<div class='inline'><p>The formatted offset.</p>
|
552
|
+
</div>
|
553
|
+
|
554
|
+
</li>
|
555
|
+
|
556
|
+
</ul>
|
557
|
+
|
558
|
+
</div><table class="source_code">
|
559
|
+
<tr>
|
560
|
+
<td>
|
561
|
+
<pre class="lines">
|
562
|
+
|
563
|
+
|
564
|
+
279
|
565
|
+
280
|
566
|
+
281
|
567
|
+
282</pre>
|
568
|
+
</td>
|
569
|
+
<td>
|
570
|
+
<pre class="code"><span class="info file"># File 'lib/lazier/datetime.rb', line 279</span>
|
571
|
+
|
572
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_format_offset'>format_offset</span><span class='lparen'>(</span><span class='id identifier rubyid_offset'>offset</span><span class='comma'>,</span> <span class='id identifier rubyid_colon'>colon</span> <span class='op'>=</span> <span class='kw'>true</span><span class='rparen'>)</span>
|
573
|
+
<span class='id identifier rubyid_offset'>offset</span> <span class='op'>=</span> <span class='lparen'>(</span><span class='id identifier rubyid_offset'>offset</span> <span class='op'>*</span> <span class='int'>86400</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_to_i'>to_i</span> <span class='kw'>if</span> <span class='id identifier rubyid_offset'>offset</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='op'>::</span><span class='const'>Rational</span><span class='rparen'>)</span>
|
574
|
+
<span class='id identifier rubyid_offset'>offset</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='op'>::</span><span class='const'>Fixnum</span><span class='rparen'>)</span> <span class='op'>?</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_seconds_to_utc_offset'>seconds_to_utc_offset</span><span class='lparen'>(</span><span class='id identifier rubyid_offset'>offset</span><span class='comma'>,</span> <span class='id identifier rubyid_colon'>colon</span><span class='rparen'>)</span> <span class='op'>:</span> <span class='kw'>nil</span>
|
575
|
+
<span class='kw'>end</span></pre>
|
576
|
+
</td>
|
577
|
+
</tr>
|
578
|
+
</table>
|
579
|
+
</div>
|
580
|
+
|
581
|
+
<div class="method_details ">
|
582
|
+
<h3 class="signature " id="list_all-instance_method">
|
583
|
+
|
584
|
+
- (<tt>Array</tt>) <strong>list_all</strong>(with_dst = true, dst_label = nil)
|
585
|
+
|
586
|
+
|
587
|
+
|
588
|
+
|
589
|
+
|
590
|
+
</h3><div class="docstring">
|
591
|
+
<div class="discussion">
|
592
|
+
<p>Returns a list of names of all timezones.</p>
|
593
|
+
|
594
|
+
|
595
|
+
</div>
|
596
|
+
</div>
|
597
|
+
<div class="tags">
|
598
|
+
<p class="tag_title">Parameters:</p>
|
599
|
+
<ul class="param">
|
600
|
+
|
601
|
+
<li>
|
602
|
+
|
603
|
+
<span class='name'>with_dst</span>
|
604
|
+
|
605
|
+
|
606
|
+
<span class='type'>(<tt><span class='object_link'><a href="../Boolean.html" title="Lazier::Boolean (module)">Boolean</a></span></tt>)</span>
|
607
|
+
|
608
|
+
|
609
|
+
<em class="default">(defaults to: <tt>true</tt>)</em>
|
610
|
+
|
611
|
+
|
612
|
+
—
|
613
|
+
<div class='inline'><p>If include DST version of the zones.</p>
|
614
|
+
</div>
|
615
|
+
|
616
|
+
</li>
|
617
|
+
|
618
|
+
<li>
|
619
|
+
|
620
|
+
<span class='name'>dst_label</span>
|
621
|
+
|
622
|
+
|
623
|
+
<span class='type'>(<tt><span class='object_link'><a href="../String.html" title="Lazier::String (module)">String</a></span></tt>)</span>
|
624
|
+
|
625
|
+
|
626
|
+
<em class="default">(defaults to: <tt>nil</tt>)</em>
|
627
|
+
|
628
|
+
|
629
|
+
—
|
630
|
+
<div class='inline'><p>Label for the DST indication. Defaults to <code>(DST)</code>.</p>
|
631
|
+
</div>
|
632
|
+
|
633
|
+
</li>
|
634
|
+
|
635
|
+
</ul>
|
636
|
+
|
637
|
+
<p class="tag_title">Returns:</p>
|
638
|
+
<ul class="return">
|
639
|
+
|
640
|
+
<li>
|
641
|
+
|
642
|
+
|
643
|
+
<span class='type'>(<tt>Array</tt>)</span>
|
644
|
+
|
645
|
+
|
646
|
+
|
647
|
+
—
|
648
|
+
<div class='inline'><p>A list of names of timezones.</p>
|
649
|
+
</div>
|
650
|
+
|
651
|
+
</li>
|
652
|
+
|
653
|
+
</ul>
|
654
|
+
|
655
|
+
</div><table class="source_code">
|
656
|
+
<tr>
|
657
|
+
<td>
|
658
|
+
<pre class="lines">
|
659
|
+
|
660
|
+
|
661
|
+
306
|
662
|
+
307
|
663
|
+
308
|
664
|
+
309
|
665
|
+
310
|
666
|
+
311
|
667
|
+
312
|
668
|
+
313
|
669
|
+
314
|
670
|
+
315
|
671
|
+
316
|
672
|
+
317
|
673
|
+
318
|
674
|
+
319
|
675
|
+
320
|
676
|
+
321
|
677
|
+
322
|
678
|
+
323
|
679
|
+
324
|
680
|
+
325</pre>
|
681
|
+
</td>
|
682
|
+
<td>
|
683
|
+
<pre class="code"><span class="info file"># File 'lib/lazier/datetime.rb', line 306</span>
|
684
|
+
|
685
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_list_all'>list_all</span><span class='lparen'>(</span><span class='id identifier rubyid_with_dst'>with_dst</span> <span class='op'>=</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='id identifier rubyid_dst_label'>dst_label</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='rparen'>)</span>
|
686
|
+
<span class='id identifier rubyid_dst_label'>dst_label</span> <span class='op'>||=</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>(DST)</span><span class='tstring_end'>"</span></span>
|
687
|
+
<span class='id identifier rubyid_dst_key'>dst_key</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>DST-</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_dst_label'>dst_label</span><span class='rbrace'>}</span><span class='tstring_end'>"</span></span>
|
688
|
+
<span class='ivar'>@zones_names</span> <span class='op'>||=</span> <span class='lbrace'>{</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>STANDARD</span><span class='tstring_end'>"</span></span> <span class='op'>=></span> <span class='op'>::</span><span class='const'>ActiveSupport</span><span class='op'>::</span><span class='const'>TimeZone</span><span class='period'>.</span><span class='id identifier rubyid_all'>all</span><span class='period'>.</span><span class='id identifier rubyid_collect'>collect</span><span class='lparen'>(</span><span class='op'>&</span><span class='symbol'>:to_s</span><span class='rparen'>)</span> <span class='rbrace'>}</span>
|
689
|
+
|
690
|
+
<span class='kw'>if</span> <span class='id identifier rubyid_with_dst'>with_dst</span> <span class='op'>&&</span> <span class='ivar'>@zones_names</span><span class='lbracket'>[</span><span class='id identifier rubyid_dst_key'>dst_key</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_blank?'>blank?</span> <span class='kw'>then</span>
|
691
|
+
<span class='ivar'>@zones_names</span><span class='lbracket'>[</span><span class='id identifier rubyid_dst_key'>dst_key</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='rbracket'>]</span>
|
692
|
+
|
693
|
+
<span class='op'>::</span><span class='const'>ActiveSupport</span><span class='op'>::</span><span class='const'>TimeZone</span><span class='period'>.</span><span class='id identifier rubyid_all'>all</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_zone'>zone</span><span class='op'>|</span>
|
694
|
+
<span class='id identifier rubyid_zone'>zone</span><span class='period'>.</span><span class='id identifier rubyid_aliases'>aliases</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_zone_alias'>zone_alias</span><span class='op'>|</span>
|
695
|
+
<span class='ivar'>@zones_names</span><span class='lbracket'>[</span><span class='id identifier rubyid_dst_key'>dst_key</span><span class='rbracket'>]</span> <span class='op'><<</span> <span class='id identifier rubyid_zone'>zone</span><span class='period'>.</span><span class='id identifier rubyid_to_str'>to_str</span><span class='lparen'>(</span><span class='id identifier rubyid_zone_alias'>zone_alias</span><span class='rparen'>)</span>
|
696
|
+
<span class='ivar'>@zones_names</span><span class='lbracket'>[</span><span class='id identifier rubyid_dst_key'>dst_key</span><span class='rbracket'>]</span> <span class='op'><<</span> <span class='id identifier rubyid_zone'>zone</span><span class='period'>.</span><span class='id identifier rubyid_to_str_with_dst'>to_str_with_dst</span><span class='lparen'>(</span><span class='id identifier rubyid_dst_label'>dst_label</span><span class='comma'>,</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='id identifier rubyid_zone_alias'>zone_alias</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_zone'>zone</span><span class='period'>.</span><span class='id identifier rubyid_uses_dst?'>uses_dst?</span> <span class='op'>&&</span> <span class='id identifier rubyid_zone_alias'>zone_alias</span> <span class='op'>!~</span> <span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>(</span><span class='embexpr_beg'>#{</span><span class='const'>Regexp</span><span class='period'>.</span><span class='id identifier rubyid_quote'>quote</span><span class='lparen'>(</span><span class='id identifier rubyid_dst_label'>dst_label</span><span class='rparen'>)</span><span class='rbrace'>}</span><span class='tstring_content'>)$</span><span class='regexp_end'>/</span></span>
|
697
|
+
<span class='kw'>end</span>
|
698
|
+
<span class='kw'>end</span>
|
699
|
+
|
700
|
+
<span class='ivar'>@zones_names</span><span class='lbracket'>[</span><span class='id identifier rubyid_dst_key'>dst_key</span><span class='rbracket'>]</span><span class='op'>=</span> <span class='ivar'>@zones_names</span><span class='lbracket'>[</span><span class='id identifier rubyid_dst_key'>dst_key</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_uniq'>uniq</span><span class='period'>.</span><span class='id identifier rubyid_compact'>compact</span><span class='period'>.</span><span class='id identifier rubyid_sort'>sort</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_a'>a</span><span class='comma'>,</span><span class='id identifier rubyid_b'>b</span><span class='op'>|</span> <span class='op'>::</span><span class='const'>ActiveSupport</span><span class='op'>::</span><span class='const'>TimeZone</span><span class='period'>.</span><span class='id identifier rubyid_compare'>compare</span><span class='lparen'>(</span><span class='id identifier rubyid_a'>a</span><span class='comma'>,</span> <span class='id identifier rubyid_b'>b</span><span class='rparen'>)</span> <span class='rbrace'>}</span> <span class='comment'># Sort by name
|
701
|
+
</span> <span class='kw'>end</span>
|
702
|
+
|
703
|
+
<span class='ivar'>@zones_names</span><span class='lbracket'>[</span><span class='id identifier rubyid_with_dst'>with_dst</span> <span class='op'>?</span> <span class='id identifier rubyid_dst_key'>dst_key</span> <span class='op'>:</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>STANDARD</span><span class='tstring_end'>"</span></span><span class='rbracket'>]</span>
|
704
|
+
<span class='kw'>end</span></pre>
|
705
|
+
</td>
|
706
|
+
</tr>
|
707
|
+
</table>
|
708
|
+
</div>
|
709
|
+
|
710
|
+
<div class="method_details ">
|
711
|
+
<h3 class="signature " id="parameterize_zone-instance_method">
|
712
|
+
|
713
|
+
- (<tt><span class='object_link'><a href="../String.html" title="Lazier::String (module)">String</a></span></tt>) <strong>parameterize_zone</strong>(tz, with_offset = true)
|
714
|
+
|
715
|
+
|
716
|
+
|
717
|
+
|
718
|
+
|
719
|
+
</h3><div class="docstring">
|
720
|
+
<div class="discussion">
|
721
|
+
<p>Returns a string representation of a timezone.</p>
|
722
|
+
|
723
|
+
<pre class="code ruby"><code><span class='const'>DateTime</span><span class='period'>.</span><span class='id identifier rubyid_parameterize_zone'>parameterize_zone</span><span class='lparen'>(</span><span class='const'>ActiveSupport</span><span class='op'>::</span><span class='const'>TimeZone</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Pacific Time (US & Canada)</span><span class='tstring_end'>"</span></span><span class='rbracket'>]</span><span class='rparen'>)</span>
|
724
|
+
<span class='comment'># => "-0800@pacific-time-us-canada"
|
725
|
+
</span></code></pre>
|
726
|
+
|
727
|
+
|
728
|
+
</div>
|
729
|
+
</div>
|
730
|
+
<div class="tags">
|
731
|
+
<p class="tag_title">Parameters:</p>
|
732
|
+
<ul class="param">
|
733
|
+
|
734
|
+
<li>
|
735
|
+
|
736
|
+
<span class='name'>tz</span>
|
737
|
+
|
738
|
+
|
739
|
+
<span class='type'>(<tt><span class='object_link'><a href="../TimeZone.html" title="Lazier::TimeZone (module)">TimeZone</a></span></tt>)</span>
|
740
|
+
|
741
|
+
|
742
|
+
|
743
|
+
—
|
744
|
+
<div class='inline'><p>The zone to represent.</p>
|
745
|
+
</div>
|
746
|
+
|
747
|
+
</li>
|
748
|
+
|
749
|
+
<li>
|
750
|
+
|
751
|
+
<span class='name'>with_offset</span>
|
752
|
+
|
753
|
+
|
754
|
+
<span class='type'>(<tt><span class='object_link'><a href="../Boolean.html" title="Lazier::Boolean (module)">Boolean</a></span></tt>)</span>
|
755
|
+
|
756
|
+
|
757
|
+
<em class="default">(defaults to: <tt>true</tt>)</em>
|
758
|
+
|
759
|
+
|
760
|
+
—
|
761
|
+
<div class='inline'><p>If to include offset into the representation.</p>
|
762
|
+
</div>
|
763
|
+
|
764
|
+
</li>
|
765
|
+
|
766
|
+
</ul>
|
767
|
+
|
768
|
+
<p class="tag_title">Returns:</p>
|
769
|
+
<ul class="return">
|
770
|
+
|
771
|
+
<li>
|
772
|
+
|
773
|
+
|
774
|
+
<span class='type'>(<tt><span class='object_link'><a href="../String.html" title="Lazier::String (module)">String</a></span></tt>)</span>
|
775
|
+
|
776
|
+
|
777
|
+
|
778
|
+
—
|
779
|
+
<div class='inline'><p>A string representation which can be used for searches.</p>
|
780
|
+
</div>
|
781
|
+
|
782
|
+
</li>
|
783
|
+
|
784
|
+
</ul>
|
785
|
+
|
786
|
+
</div><table class="source_code">
|
787
|
+
<tr>
|
788
|
+
<td>
|
789
|
+
<pre class="lines">
|
790
|
+
|
791
|
+
|
792
|
+
336
|
793
|
+
337
|
794
|
+
338
|
795
|
+
339
|
796
|
+
340
|
797
|
+
341
|
798
|
+
342
|
799
|
+
343
|
800
|
+
344
|
801
|
+
345
|
802
|
+
346</pre>
|
803
|
+
</td>
|
804
|
+
<td>
|
805
|
+
<pre class="code"><span class="info file"># File 'lib/lazier/datetime.rb', line 336</span>
|
806
|
+
|
807
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_parameterize_zone'>parameterize_zone</span><span class='lparen'>(</span><span class='id identifier rubyid_tz'>tz</span><span class='comma'>,</span> <span class='id identifier rubyid_with_offset'>with_offset</span> <span class='op'>=</span> <span class='kw'>true</span><span class='rparen'>)</span>
|
808
|
+
<span class='id identifier rubyid_tz'>tz</span> <span class='op'>=</span> <span class='id identifier rubyid_tz'>tz</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span> <span class='kw'>if</span> <span class='op'>!</span><span class='id identifier rubyid_tz'>tz</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='op'>::</span><span class='const'>String</span><span class='rparen'>)</span>
|
809
|
+
|
810
|
+
<span class='kw'>if</span> <span class='id identifier rubyid_tz'>tz</span> <span class='op'>=~</span> <span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>^(\([a-z]+([+-])(\d{2})(:?)(\d{2})\)\s(.+))$</span><span class='regexp_end'>/i</span></span> <span class='kw'>then</span>
|
811
|
+
<span class='id identifier rubyid_with_offset'>with_offset</span> <span class='op'>?</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='embexpr_beg'>#{</span><span class='backref'>$2</span><span class='rbrace'>}</span><span class='embexpr_beg'>#{</span><span class='backref'>$3</span><span class='rbrace'>}</span><span class='embexpr_beg'>#{</span><span class='backref'>$5</span><span class='rbrace'>}</span><span class='tstring_content'>@</span><span class='embexpr_beg'>#{</span><span class='backref'>$6</span><span class='period'>.</span><span class='id identifier rubyid_parameterize'>parameterize</span><span class='rbrace'>}</span><span class='tstring_end'>"</span></span> <span class='op'>:</span> <span class='backref'>$6</span><span class='period'>.</span><span class='id identifier rubyid_parameterize'>parameterize</span>
|
812
|
+
<span class='kw'>elsif</span> <span class='op'>!</span><span class='id identifier rubyid_with_offset'>with_offset</span> <span class='kw'>then</span>
|
813
|
+
<span class='id identifier rubyid_tz'>tz</span><span class='period'>.</span><span class='id identifier rubyid_gsub'>gsub</span><span class='lparen'>(</span><span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>^([+-]?(\d{2})(:?)(\d{2})@)</span><span class='regexp_end'>/</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span>
|
814
|
+
<span class='kw'>else</span>
|
815
|
+
<span class='id identifier rubyid_tz'>tz</span><span class='period'>.</span><span class='id identifier rubyid_parameterize'>parameterize</span>
|
816
|
+
<span class='kw'>end</span>
|
817
|
+
<span class='kw'>end</span></pre>
|
818
|
+
</td>
|
819
|
+
</tr>
|
820
|
+
</table>
|
821
|
+
</div>
|
822
|
+
|
823
|
+
<div class="method_details ">
|
824
|
+
<h3 class="signature " id="rationalize_offset-instance_method">
|
825
|
+
|
826
|
+
- (<tt>Rational</tt>) <strong>rationalize_offset</strong>(offset)
|
827
|
+
|
828
|
+
|
829
|
+
|
830
|
+
|
831
|
+
|
832
|
+
</h3><div class="docstring">
|
833
|
+
<div class="discussion">
|
834
|
+
<p>Returns an offset in rational value.</p>
|
835
|
+
|
836
|
+
|
837
|
+
</div>
|
838
|
+
</div>
|
839
|
+
<div class="tags">
|
840
|
+
<p class="tag_title">Parameters:</p>
|
841
|
+
<ul class="param">
|
842
|
+
|
843
|
+
<li>
|
844
|
+
|
845
|
+
<span class='name'>offset</span>
|
846
|
+
|
847
|
+
|
848
|
+
<span class='type'>(<tt>Fixnum</tt>)</span>
|
849
|
+
|
850
|
+
|
851
|
+
|
852
|
+
—
|
853
|
+
<div class='inline'><p>The offset to convert.</p>
|
854
|
+
</div>
|
855
|
+
|
856
|
+
</li>
|
857
|
+
|
858
|
+
</ul>
|
859
|
+
|
860
|
+
<p class="tag_title">Returns:</p>
|
861
|
+
<ul class="return">
|
862
|
+
|
863
|
+
<li>
|
864
|
+
|
865
|
+
|
866
|
+
<span class='type'>(<tt>Rational</tt>)</span>
|
867
|
+
|
868
|
+
|
869
|
+
|
870
|
+
—
|
871
|
+
<div class='inline'><p>The converted offset.</p>
|
872
|
+
</div>
|
873
|
+
|
874
|
+
</li>
|
875
|
+
|
876
|
+
</ul>
|
877
|
+
|
878
|
+
</div><table class="source_code">
|
879
|
+
<tr>
|
880
|
+
<td>
|
881
|
+
<pre class="lines">
|
882
|
+
|
883
|
+
|
884
|
+
269
|
885
|
+
270
|
886
|
+
271
|
887
|
+
272</pre>
|
888
|
+
</td>
|
889
|
+
<td>
|
890
|
+
<pre class="code"><span class="info file"># File 'lib/lazier/datetime.rb', line 269</span>
|
891
|
+
|
892
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_rationalize_offset'>rationalize_offset</span><span class='lparen'>(</span><span class='id identifier rubyid_offset'>offset</span><span class='rparen'>)</span>
|
893
|
+
<span class='id identifier rubyid_offset'>offset</span> <span class='op'>=</span> <span class='id identifier rubyid_offset'>offset</span><span class='period'>.</span><span class='id identifier rubyid_try'>try</span><span class='lparen'>(</span><span class='symbol'>:offset</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='op'>!</span><span class='id identifier rubyid_offset'>offset</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='op'>::</span><span class='const'>Fixnum</span><span class='rparen'>)</span>
|
894
|
+
<span class='op'>::</span><span class='const'>TZInfo</span><span class='op'>::</span><span class='const'>OffsetRationals</span><span class='period'>.</span><span class='id identifier rubyid_rational_for_offset'>rational_for_offset</span><span class='lparen'>(</span><span class='id identifier rubyid_offset'>offset</span><span class='period'>.</span><span class='id identifier rubyid_to_integer'>to_integer</span><span class='rparen'>)</span>
|
895
|
+
<span class='kw'>end</span></pre>
|
896
|
+
</td>
|
897
|
+
</tr>
|
898
|
+
</table>
|
899
|
+
</div>
|
900
|
+
|
901
|
+
<div class="method_details ">
|
902
|
+
<h3 class="signature " id="unparameterize_zone-instance_method">
|
903
|
+
|
904
|
+
- (<tt><span class='object_link'><a href="../String.html" title="Lazier::String (module)">String</a></span>|<span class='object_link'><a href="../TimeZone.html" title="Lazier::TimeZone (module)">TimeZone</a></span></tt>) <strong>unparameterize_zone</strong>(tz, as_string = false, dst_label = nil)
|
905
|
+
|
906
|
+
|
907
|
+
|
908
|
+
|
909
|
+
|
910
|
+
</h3><div class="docstring">
|
911
|
+
<div class="discussion">
|
912
|
+
<p>Finds a parameterized timezone.</p>
|
913
|
+
|
914
|
+
|
915
|
+
</div>
|
916
|
+
</div>
|
917
|
+
<div class="tags">
|
918
|
+
<p class="tag_title">Parameters:</p>
|
919
|
+
<ul class="param">
|
920
|
+
|
921
|
+
<li>
|
922
|
+
|
923
|
+
<span class='name'>tz</span>
|
924
|
+
|
925
|
+
|
926
|
+
<span class='type'>(<tt><span class='object_link'><a href="../String.html" title="Lazier::String (module)">String</a></span></tt>)</span>
|
927
|
+
|
928
|
+
|
929
|
+
|
930
|
+
—
|
931
|
+
<div class='inline'><p>The zone to unparameterize.</p>
|
932
|
+
</div>
|
933
|
+
|
934
|
+
</li>
|
935
|
+
|
936
|
+
<li>
|
937
|
+
|
938
|
+
<span class='name'>as_string</span>
|
939
|
+
|
940
|
+
|
941
|
+
<span class='type'>(<tt><span class='object_link'><a href="../Boolean.html" title="Lazier::Boolean (module)">Boolean</a></span></tt>)</span>
|
942
|
+
|
943
|
+
|
944
|
+
<em class="default">(defaults to: <tt>false</tt>)</em>
|
945
|
+
|
946
|
+
|
947
|
+
—
|
948
|
+
<div class='inline'><p>If return just the zone name.</p>
|
949
|
+
</div>
|
950
|
+
|
951
|
+
</li>
|
952
|
+
|
953
|
+
<li>
|
954
|
+
|
955
|
+
<span class='name'>dst_label</span>
|
956
|
+
|
957
|
+
|
958
|
+
<span class='type'>(<tt><span class='object_link'><a href="../String.html" title="Lazier::String (module)">String</a></span></tt>)</span>
|
959
|
+
|
960
|
+
|
961
|
+
<em class="default">(defaults to: <tt>nil</tt>)</em>
|
962
|
+
|
963
|
+
|
964
|
+
—
|
965
|
+
<div class='inline'><p>Label for the DST indication. Defaults to <code>(DST)</code>.</p>
|
966
|
+
</div>
|
967
|
+
|
968
|
+
</li>
|
969
|
+
|
970
|
+
</ul>
|
971
|
+
|
972
|
+
<p class="tag_title">Returns:</p>
|
973
|
+
<ul class="return">
|
974
|
+
|
975
|
+
<li>
|
976
|
+
|
977
|
+
|
978
|
+
<span class='type'>(<tt><span class='object_link'><a href="../String.html" title="Lazier::String (module)">String</a></span>|<span class='object_link'><a href="../TimeZone.html" title="Lazier::TimeZone (module)">TimeZone</a></span></tt>)</span>
|
979
|
+
|
980
|
+
|
981
|
+
|
982
|
+
—
|
983
|
+
<div class='inline'><p>The found timezone or <code>nil</code> if the zone is not valid.</p>
|
984
|
+
</div>
|
985
|
+
|
986
|
+
</li>
|
987
|
+
|
988
|
+
</ul>
|
989
|
+
|
990
|
+
<p class="tag_title">See Also:</p>
|
991
|
+
<ul class="see">
|
992
|
+
|
993
|
+
<li>DateTime#parameterize_zone</li>
|
994
|
+
|
995
|
+
</ul>
|
996
|
+
|
997
|
+
</div><table class="source_code">
|
998
|
+
<tr>
|
999
|
+
<td>
|
1000
|
+
<pre class="lines">
|
1001
|
+
|
1002
|
+
|
1003
|
+
355
|
1004
|
+
356
|
1005
|
+
357
|
1006
|
+
358
|
1007
|
+
359
|
1008
|
+
360
|
1009
|
+
361
|
1010
|
+
362
|
1011
|
+
363
|
1012
|
+
364
|
1013
|
+
365
|
1014
|
+
366
|
1015
|
+
367
|
1016
|
+
368
|
1017
|
+
369
|
1018
|
+
370</pre>
|
1019
|
+
</td>
|
1020
|
+
<td>
|
1021
|
+
<pre class="code"><span class="info file"># File 'lib/lazier/datetime.rb', line 355</span>
|
1022
|
+
|
1023
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_unparameterize_zone'>unparameterize_zone</span><span class='lparen'>(</span><span class='id identifier rubyid_tz'>tz</span><span class='comma'>,</span> <span class='id identifier rubyid_as_string'>as_string</span> <span class='op'>=</span> <span class='kw'>false</span><span class='comma'>,</span> <span class='id identifier rubyid_dst_label'>dst_label</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='rparen'>)</span>
|
1024
|
+
<span class='id identifier rubyid_tz'>tz</span> <span class='op'>=</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_parameterize_zone'>parameterize_zone</span><span class='lparen'>(</span><span class='id identifier rubyid_tz'>tz</span><span class='comma'>,</span> <span class='kw'>false</span><span class='rparen'>)</span>
|
1025
|
+
<span class='id identifier rubyid_rv'>rv</span> <span class='op'>=</span> <span class='id identifier rubyid_catch'>catch</span><span class='lparen'>(</span><span class='symbol'>:zone</span><span class='rparen'>)</span> <span class='kw'>do</span>
|
1026
|
+
<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_list_all'>list_all</span><span class='lparen'>(</span><span class='kw'>true</span><span class='comma'>,</span> <span class='id identifier rubyid_dst_label'>dst_label</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_zone'>zone</span><span class='op'>|</span>
|
1027
|
+
<span class='id identifier rubyid_throw'>throw</span><span class='lparen'>(</span><span class='symbol'>:zone</span><span class='comma'>,</span> <span class='id identifier rubyid_zone'>zone</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_parameterize_zone'>parameterize_zone</span><span class='lparen'>(</span><span class='id identifier rubyid_zone'>zone</span><span class='comma'>,</span> <span class='kw'>false</span><span class='rparen'>)</span> <span class='op'>=~</span> <span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>(</span><span class='embexpr_beg'>#{</span><span class='const'>Regexp</span><span class='period'>.</span><span class='id identifier rubyid_quote'>quote</span><span class='lparen'>(</span><span class='id identifier rubyid_tz'>tz</span><span class='rparen'>)</span><span class='rbrace'>}</span><span class='tstring_content'>)$</span><span class='regexp_end'>/</span></span>
|
1028
|
+
<span class='kw'>end</span>
|
1029
|
+
|
1030
|
+
<span class='kw'>nil</span>
|
1031
|
+
<span class='kw'>end</span>
|
1032
|
+
|
1033
|
+
<span class='kw'>if</span> <span class='id identifier rubyid_rv'>rv</span> <span class='kw'>then</span>
|
1034
|
+
<span class='lparen'>(</span><span class='id identifier rubyid_as_string'>as_string</span> <span class='op'>?</span> <span class='id identifier rubyid_rv'>rv</span> <span class='op'>:</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_find'>find</span><span class='lparen'>(</span><span class='id identifier rubyid_rv'>rv</span><span class='comma'>,</span> <span class='id identifier rubyid_dst_label'>dst_label</span><span class='rparen'>)</span><span class='rparen'>)</span>
|
1035
|
+
<span class='kw'>else</span>
|
1036
|
+
<span class='kw'>nil</span>
|
1037
|
+
<span class='kw'>end</span>
|
1038
|
+
<span class='kw'>end</span></pre>
|
1039
|
+
</td>
|
1040
|
+
</tr>
|
1041
|
+
</table>
|
1042
|
+
</div>
|
1043
|
+
|
1044
|
+
</div>
|
1045
|
+
|
1046
|
+
</div>
|
1047
|
+
|
1048
|
+
<div id="footer">
|
1049
|
+
Generated on Wed Aug 1 08:57:56 2012 by
|
1050
|
+
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
1051
|
+
0.8.2.1 (ruby-1.9.2).
|
1052
|
+
</div>
|
1053
|
+
|
1054
|
+
</body>
|
1055
|
+
</html>
|