time_with_zone 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/README.md +48 -2
- data/docs/TimeWithZone.html +278 -33
- data/docs/_index.html +1 -1
- data/docs/file.LICENSE.html +1 -1
- data/docs/file.README.html +60 -3
- data/docs/index.html +60 -3
- data/docs/method_list.html +14 -2
- data/docs/top-level-namespace.html +1 -1
- data/lib/time_with_zone.rb +33 -1
- data/lib/time_with_zone/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5c88ea61d8793644919fa066f7e4041a1b053c42
|
4
|
+
data.tar.gz: 19d60b87e1c253bc59a92266949f0199305cc913
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 83a423700adeb24fd29cbcca995d2df2784305619cdf3c7a276fc9f1c50fe073fe6da6905291c70325e00110fb569659c311c9bec64745ce417acc1e08df2f97
|
7
|
+
data.tar.gz: 72fcc6e21b186b999e04913d8873f53c1e17a4ea576f359eb69741597483f38ac9ef1b00a4cce65c5e69eae47e3ac560539e9a4535c69743695f869a94c79d38
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# TimeWithZone
|
2
2
|
|
3
|
-
Handle time with zone without ActiveSupport or `ENV['TZ']` for thread-safety.
|
3
|
+
Handle time with zone without ActiveSupport, or `ENV['TZ']` for thread-safety.
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
@@ -20,7 +20,53 @@ Or install it yourself as:
|
|
20
20
|
|
21
21
|
## Usage
|
22
22
|
|
23
|
-
|
23
|
+
Assume your localtime zone is `+09:00` (`Asia/Tokyo`):
|
24
|
+
|
25
|
+
```ruby
|
26
|
+
require 'time'
|
27
|
+
|
28
|
+
Time.strptime('2015-01-01', '%Y-%m-%d')
|
29
|
+
#=> 2015-01-01 00:00:00 +0900
|
30
|
+
```
|
31
|
+
|
32
|
+
But, you want to get time in `+08:00` (`Asia/Taipei`) as `2015-01-01 00:00:00 +0800`.
|
33
|
+
|
34
|
+
If the timezone format is in numeric formats such as `[+-]HH:MM`, `[+-]HHMM`, `[+-]HH`, you may use `%z` of strptime:
|
35
|
+
|
36
|
+
```ruby
|
37
|
+
require 'time'
|
38
|
+
|
39
|
+
date = '2015-01-01'
|
40
|
+
timezone = '+08:00'
|
41
|
+
Time.strptime("#{date} #{timezone}", '%Y-%m-%d %z')
|
42
|
+
#=> 2015-01-01 00:00:00 +0800
|
43
|
+
```
|
44
|
+
|
45
|
+
However, if the timezone format is in the `Region/Zone` format such as `Asia/Taipei`, `%Z` or `%z` won't work. So, use `time_with_zone` gem as:
|
46
|
+
|
47
|
+
|
48
|
+
```ruby
|
49
|
+
require 'time_with_zone'
|
50
|
+
|
51
|
+
TimeWithZone.strptime_with_zone('2015-01-01', '%Y-%m-%d', 'Asia/Taipei')
|
52
|
+
#=> 2015-01-01 00:00:00 +0800
|
53
|
+
```
|
54
|
+
|
55
|
+
TimeWithZone gem accepts numeric formats, and the `Region/Zone` format, and some of short-abbreviations of timezone such as UTC.
|
56
|
+
|
57
|
+
## Documents
|
58
|
+
|
59
|
+
Available methods are:
|
60
|
+
|
61
|
+
* strptime_with_zone(str, format, timezone)
|
62
|
+
* parse_with_zone(str, timezone)
|
63
|
+
* set_zone(time, timezone)
|
64
|
+
* zone_offset(timezone, time = nil)
|
65
|
+
* strptime_with_zone_offset(str, format, zone_offset)
|
66
|
+
* parse_with_zone_offset(str, zone_offset)
|
67
|
+
* set_zone_offset(time, zone_offset)
|
68
|
+
|
69
|
+
See [docs](https://sonots.github.io/time_with_zone/TimeWithZone.html) for details
|
24
70
|
|
25
71
|
## Development
|
26
72
|
|
data/docs/TimeWithZone.html
CHANGED
@@ -192,7 +192,7 @@
|
|
192
192
|
<dt id="VERSION-constant" class="">VERSION =
|
193
193
|
|
194
194
|
</dt>
|
195
|
-
<dd><pre class="code"><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>0.
|
195
|
+
<dd><pre class="code"><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>0.3.0</span><span class='tstring_end'>"</span></span></pre></dd>
|
196
196
|
|
197
197
|
</dl>
|
198
198
|
|
@@ -280,6 +280,30 @@
|
|
280
280
|
<p>Time.parse with timezone.</p>
|
281
281
|
</div></span>
|
282
282
|
|
283
|
+
</li>
|
284
|
+
|
285
|
+
|
286
|
+
<li class="public ">
|
287
|
+
<span class="summary_signature">
|
288
|
+
|
289
|
+
<a href="#parse_with_zone_offset-class_method" title="parse_with_zone_offset (class method)">+ (Time) <strong>parse_with_zone_offset</strong>(date, zone_offset) </a>
|
290
|
+
|
291
|
+
|
292
|
+
|
293
|
+
</span>
|
294
|
+
|
295
|
+
|
296
|
+
|
297
|
+
|
298
|
+
|
299
|
+
|
300
|
+
|
301
|
+
|
302
|
+
|
303
|
+
<span class="summary_desc"><div class='inline'>
|
304
|
+
<p>Time.parse with zone_offset.</p>
|
305
|
+
</div></span>
|
306
|
+
|
283
307
|
</li>
|
284
308
|
|
285
309
|
|
@@ -352,6 +376,30 @@
|
|
352
376
|
<p>Time.strptime with timezone.</p>
|
353
377
|
</div></span>
|
354
378
|
|
379
|
+
</li>
|
380
|
+
|
381
|
+
|
382
|
+
<li class="public ">
|
383
|
+
<span class="summary_signature">
|
384
|
+
|
385
|
+
<a href="#strptime_with_zone_offset-class_method" title="strptime_with_zone_offset (class method)">+ (Time) <strong>strptime_with_zone_offset</strong>(date, format, zone_offset) </a>
|
386
|
+
|
387
|
+
|
388
|
+
|
389
|
+
</span>
|
390
|
+
|
391
|
+
|
392
|
+
|
393
|
+
|
394
|
+
|
395
|
+
|
396
|
+
|
397
|
+
|
398
|
+
|
399
|
+
<span class="summary_desc"><div class='inline'>
|
400
|
+
<p>Time.strptime with zone_offset.</p>
|
401
|
+
</div></span>
|
402
|
+
|
355
403
|
</li>
|
356
404
|
|
357
405
|
|
@@ -430,7 +478,7 @@
|
|
430
478
|
<pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_require'>require</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>time_with_zone</span><span class='tstring_end'>'</span></span>
|
431
479
|
<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'>"</span><span class='tstring_content'>2016-10-20 00:00:00 +00:00</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span>
|
432
480
|
|
433
|
-
<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='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'>"</span><span class='tstring_content'>Asia/Taipei</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span><span class='rparen'>)</span>
|
481
|
+
<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='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'>"</span><span class='tstring_content'>Asia/Taipei</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='id identifier rubyid_time'>time</span><span class='rparen'>)</span><span class='rparen'>)</span>
|
434
482
|
<span class='comment'>#=> 2010-10-20 08:00:00 +0800
|
435
483
|
</span></code></pre>
|
436
484
|
|
@@ -722,6 +770,99 @@
|
|
722
770
|
</td>
|
723
771
|
</tr>
|
724
772
|
</table>
|
773
|
+
</div>
|
774
|
+
|
775
|
+
<div class="method_details ">
|
776
|
+
<h3 class="signature " id="parse_with_zone_offset-class_method">
|
777
|
+
|
778
|
+
+ (<tt>Time</tt>) <strong>parse_with_zone_offset</strong>(date, zone_offset)
|
779
|
+
|
780
|
+
|
781
|
+
|
782
|
+
|
783
|
+
|
784
|
+
</h3><div class="docstring">
|
785
|
+
<div class="discussion">
|
786
|
+
|
787
|
+
<p>Time.parse with zone_offset</p>
|
788
|
+
|
789
|
+
<pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_require'>require</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>time_with_zone</span><span class='tstring_end'>'</span></span>
|
790
|
+
|
791
|
+
<span class='const'>TimeWithZone</span><span class='period'>.</span><span class='id identifier rubyid_parse_with_zone_offset'>parse_with_zone_offset</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>2016-10-20</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='int'>28800</span><span class='rparen'>)</span>
|
792
|
+
<span class='comment'>#=> 2016-10-20 00:00:00 +0800
|
793
|
+
</span></code></pre>
|
794
|
+
|
795
|
+
|
796
|
+
</div>
|
797
|
+
</div>
|
798
|
+
<div class="tags">
|
799
|
+
<p class="tag_title">Parameters:</p>
|
800
|
+
<ul class="param">
|
801
|
+
|
802
|
+
<li>
|
803
|
+
|
804
|
+
<span class='name'>date</span>
|
805
|
+
|
806
|
+
|
807
|
+
<span class='type'>(<tt>String</tt>)</span>
|
808
|
+
|
809
|
+
|
810
|
+
|
811
|
+
—
|
812
|
+
<div class='inline'>
|
813
|
+
<p>string to be parsed</p>
|
814
|
+
</div>
|
815
|
+
|
816
|
+
</li>
|
817
|
+
|
818
|
+
<li>
|
819
|
+
|
820
|
+
<span class='name'>zone_offset</span>
|
821
|
+
|
822
|
+
|
823
|
+
<span class='type'>(<tt>Integer</tt>)</span>
|
824
|
+
|
825
|
+
|
826
|
+
|
827
|
+
</li>
|
828
|
+
|
829
|
+
</ul>
|
830
|
+
|
831
|
+
<p class="tag_title">Returns:</p>
|
832
|
+
<ul class="return">
|
833
|
+
|
834
|
+
<li>
|
835
|
+
|
836
|
+
|
837
|
+
<span class='type'>(<tt>Time</tt>)</span>
|
838
|
+
|
839
|
+
|
840
|
+
|
841
|
+
</li>
|
842
|
+
|
843
|
+
</ul>
|
844
|
+
|
845
|
+
</div><table class="source_code">
|
846
|
+
<tr>
|
847
|
+
<td>
|
848
|
+
<pre class="lines">
|
849
|
+
|
850
|
+
|
851
|
+
126
|
852
|
+
127
|
853
|
+
128
|
854
|
+
129</pre>
|
855
|
+
</td>
|
856
|
+
<td>
|
857
|
+
<pre class="code"><span class="info file"># File 'lib/time_with_zone.rb', line 126</span>
|
858
|
+
|
859
|
+
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_parse_with_zone_offset'>parse_with_zone_offset</span><span class='lparen'>(</span><span class='id identifier rubyid_date'>date</span><span class='comma'>,</span> <span class='id identifier rubyid_zone_offset'>zone_offset</span><span class='rparen'>)</span>
|
860
|
+
<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>
|
861
|
+
<span class='id identifier rubyid_set_zone_offset!'>set_zone_offset!</span><span class='lparen'>(</span><span class='id identifier rubyid_time'>time</span><span class='comma'>,</span> <span class='id identifier rubyid_zone_offset'>zone_offset</span><span class='rparen'>)</span>
|
862
|
+
<span class='kw'>end</span></pre>
|
863
|
+
</td>
|
864
|
+
</tr>
|
865
|
+
</table>
|
725
866
|
</div>
|
726
867
|
|
727
868
|
<div class="method_details ">
|
@@ -797,12 +938,12 @@
|
|
797
938
|
<pre class="lines">
|
798
939
|
|
799
940
|
|
800
|
-
|
801
|
-
|
802
|
-
|
941
|
+
193
|
942
|
+
194
|
943
|
+
195</pre>
|
803
944
|
</td>
|
804
945
|
<td>
|
805
|
-
<pre class="code"><span class="info file"># File 'lib/time_with_zone.rb', line
|
946
|
+
<pre class="code"><span class="info file"># File 'lib/time_with_zone.rb', line 193</span>
|
806
947
|
|
807
948
|
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_set_zone'>set_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>
|
808
949
|
<span class='id identifier rubyid_set_zone!'>set_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>
|
@@ -885,12 +1026,12 @@
|
|
885
1026
|
<pre class="lines">
|
886
1027
|
|
887
1028
|
|
888
|
-
|
889
|
-
|
890
|
-
|
1029
|
+
209
|
1030
|
+
210
|
1031
|
+
211</pre>
|
891
1032
|
</td>
|
892
1033
|
<td>
|
893
|
-
<pre class="code"><span class="info file"># File 'lib/time_with_zone.rb', line
|
1034
|
+
<pre class="code"><span class="info file"># File 'lib/time_with_zone.rb', line 209</span>
|
894
1035
|
|
895
1036
|
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_set_zone_offset'>set_zone_offset</span><span class='lparen'>(</span><span class='id identifier rubyid_time'>time</span><span class='comma'>,</span> <span class='id identifier rubyid_zone_offset'>zone_offset</span><span class='rparen'>)</span>
|
896
1037
|
<span class='id identifier rubyid_set_zone_offset!'>set_zone_offset!</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_zone_offset'>zone_offset</span><span class='rparen'>)</span>
|
@@ -1009,13 +1150,13 @@
|
|
1009
1150
|
<pre class="lines">
|
1010
1151
|
|
1011
1152
|
|
1012
|
-
|
1013
|
-
|
1014
|
-
|
1015
|
-
|
1153
|
+
160
|
1154
|
+
161
|
1155
|
+
162
|
1156
|
+
163</pre>
|
1016
1157
|
</td>
|
1017
1158
|
<td>
|
1018
|
-
<pre class="code"><span class="info file"># File 'lib/time_with_zone.rb', line
|
1159
|
+
<pre class="code"><span class="info file"># File 'lib/time_with_zone.rb', line 160</span>
|
1019
1160
|
|
1020
1161
|
<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>
|
1021
1162
|
<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>
|
@@ -1024,6 +1165,110 @@
|
|
1024
1165
|
</td>
|
1025
1166
|
</tr>
|
1026
1167
|
</table>
|
1168
|
+
</div>
|
1169
|
+
|
1170
|
+
<div class="method_details ">
|
1171
|
+
<h3 class="signature " id="strptime_with_zone_offset-class_method">
|
1172
|
+
|
1173
|
+
+ (<tt>Time</tt>) <strong>strptime_with_zone_offset</strong>(date, format, zone_offset)
|
1174
|
+
|
1175
|
+
|
1176
|
+
|
1177
|
+
|
1178
|
+
|
1179
|
+
</h3><div class="docstring">
|
1180
|
+
<div class="discussion">
|
1181
|
+
|
1182
|
+
<p>Time.strptime with zone_offset</p>
|
1183
|
+
|
1184
|
+
<pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_require'>require</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>time_with_zone</span><span class='tstring_end'>'</span></span>
|
1185
|
+
|
1186
|
+
<span class='const'>TimeWithZone</span><span class='period'>.</span><span class='id identifier rubyid_strptime_with_zone_offset'>strptime_with_zone_offset</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>2016-10-20</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>%Y-%m-%d</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='int'>28800</span><span class='rparen'>)</span>
|
1187
|
+
<span class='comment'>#=> 2016-10-20 00:00:00 +0800
|
1188
|
+
</span></code></pre>
|
1189
|
+
|
1190
|
+
|
1191
|
+
</div>
|
1192
|
+
</div>
|
1193
|
+
<div class="tags">
|
1194
|
+
<p class="tag_title">Parameters:</p>
|
1195
|
+
<ul class="param">
|
1196
|
+
|
1197
|
+
<li>
|
1198
|
+
|
1199
|
+
<span class='name'>date</span>
|
1200
|
+
|
1201
|
+
|
1202
|
+
<span class='type'>(<tt>String</tt>)</span>
|
1203
|
+
|
1204
|
+
|
1205
|
+
|
1206
|
+
—
|
1207
|
+
<div class='inline'>
|
1208
|
+
<p>string to be parsed</p>
|
1209
|
+
</div>
|
1210
|
+
|
1211
|
+
</li>
|
1212
|
+
|
1213
|
+
<li>
|
1214
|
+
|
1215
|
+
<span class='name'>format</span>
|
1216
|
+
|
1217
|
+
|
1218
|
+
<span class='type'>(<tt>String</tt>)</span>
|
1219
|
+
|
1220
|
+
|
1221
|
+
|
1222
|
+
</li>
|
1223
|
+
|
1224
|
+
<li>
|
1225
|
+
|
1226
|
+
<span class='name'>zone_offset</span>
|
1227
|
+
|
1228
|
+
|
1229
|
+
<span class='type'>(<tt>Integer</tt>)</span>
|
1230
|
+
|
1231
|
+
|
1232
|
+
|
1233
|
+
</li>
|
1234
|
+
|
1235
|
+
</ul>
|
1236
|
+
|
1237
|
+
<p class="tag_title">Returns:</p>
|
1238
|
+
<ul class="return">
|
1239
|
+
|
1240
|
+
<li>
|
1241
|
+
|
1242
|
+
|
1243
|
+
<span class='type'>(<tt>Time</tt>)</span>
|
1244
|
+
|
1245
|
+
|
1246
|
+
|
1247
|
+
</li>
|
1248
|
+
|
1249
|
+
</ul>
|
1250
|
+
|
1251
|
+
</div><table class="source_code">
|
1252
|
+
<tr>
|
1253
|
+
<td>
|
1254
|
+
<pre class="lines">
|
1255
|
+
|
1256
|
+
|
1257
|
+
176
|
1258
|
+
177
|
1259
|
+
178
|
1260
|
+
179</pre>
|
1261
|
+
</td>
|
1262
|
+
<td>
|
1263
|
+
<pre class="code"><span class="info file"># File 'lib/time_with_zone.rb', line 176</span>
|
1264
|
+
|
1265
|
+
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_strptime_with_zone_offset'>strptime_with_zone_offset</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_zone_offset'>zone_offset</span><span class='rparen'>)</span>
|
1266
|
+
<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>
|
1267
|
+
<span class='id identifier rubyid_set_zone_offset!'>set_zone_offset!</span><span class='lparen'>(</span><span class='id identifier rubyid_time'>time</span><span class='comma'>,</span> <span class='id identifier rubyid_zone_offset'>zone_offset</span><span class='rparen'>)</span>
|
1268
|
+
<span class='kw'>end</span></pre>
|
1269
|
+
</td>
|
1270
|
+
</tr>
|
1271
|
+
</table>
|
1027
1272
|
</div>
|
1028
1273
|
|
1029
1274
|
<div class="method_details ">
|
@@ -1124,25 +1369,25 @@
|
|
1124
1369
|
<pre class="lines">
|
1125
1370
|
|
1126
1371
|
|
1127
|
-
|
1128
|
-
|
1129
|
-
|
1130
|
-
|
1131
|
-
|
1132
|
-
|
1133
|
-
|
1134
|
-
|
1135
|
-
|
1136
|
-
|
1137
|
-
|
1138
|
-
|
1139
|
-
|
1140
|
-
|
1141
|
-
|
1142
|
-
|
1372
|
+
233
|
1373
|
+
234
|
1374
|
+
235
|
1375
|
+
236
|
1376
|
+
237
|
1377
|
+
238
|
1378
|
+
239
|
1379
|
+
240
|
1380
|
+
241
|
1381
|
+
242
|
1382
|
+
243
|
1383
|
+
244
|
1384
|
+
245
|
1385
|
+
246
|
1386
|
+
247
|
1387
|
+
248</pre>
|
1143
1388
|
</td>
|
1144
1389
|
<td>
|
1145
|
-
<pre class="code"><span class="info file"># File 'lib/time_with_zone.rb', line
|
1390
|
+
<pre class="code"><span class="info file"># File 'lib/time_with_zone.rb', line 233</span>
|
1146
1391
|
|
1147
1392
|
<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>
|
1148
1393
|
<span class='kw'>if</span> <span class='const'>NUMERIC_PATTERN</span> <span class='op'>===</span> <span class='id identifier rubyid_timezone'>timezone</span>
|
@@ -1170,7 +1415,7 @@
|
|
1170
1415
|
</div>
|
1171
1416
|
|
1172
1417
|
<div id="footer">
|
1173
|
-
Generated on Mon Oct 31
|
1418
|
+
Generated on Mon Oct 31 21:29:32 2016 by
|
1174
1419
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
1175
1420
|
0.8.7.6 (ruby-2.3.0).
|
1176
1421
|
</div>
|
data/docs/_index.html
CHANGED
@@ -104,7 +104,7 @@
|
|
104
104
|
</div>
|
105
105
|
|
106
106
|
<div id="footer">
|
107
|
-
Generated on Mon Oct 31
|
107
|
+
Generated on Mon Oct 31 21:29:31 2016 by
|
108
108
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
109
109
|
0.8.7.6 (ruby-2.3.0).
|
110
110
|
</div>
|
data/docs/file.LICENSE.html
CHANGED
@@ -64,7 +64,7 @@
|
|
64
64
|
<div id="content"><div id='filecontents'>The MIT License (MIT)<br/><br/>Copyright (c) 2016 Naotoshi Seo<br/><br/>Permission is hereby granted, free of charge, to any person obtaining a copy<br/>of this software and associated documentation files (the "Software"), to deal<br/>in the Software without restriction, including without limitation the rights<br/>to use, copy, modify, merge, publish, distribute, sublicense, and/or sell<br/>copies of the Software, and to permit persons to whom the Software is<br/>furnished to do so, subject to the following conditions:<br/><br/>The above copyright notice and this permission notice shall be included in<br/>all copies or substantial portions of the Software.<br/><br/>THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR<br/>IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,<br/>FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE<br/>AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER<br/>LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,<br/>OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN<br/>THE SOFTWARE.</div></div>
|
65
65
|
|
66
66
|
<div id="footer">
|
67
|
-
Generated on Mon Oct 31
|
67
|
+
Generated on Mon Oct 31 21:29:31 2016 by
|
68
68
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
69
69
|
0.8.7.6 (ruby-2.3.0).
|
70
70
|
</div>
|
data/docs/file.README.html
CHANGED
@@ -64,7 +64,7 @@
|
|
64
64
|
<div id="content"><div id='filecontents'>
|
65
65
|
<h1 id="label-TimeWithZone">TimeWithZone</h1>
|
66
66
|
|
67
|
-
<p>Handle time with zone without ActiveSupport or <code>ENV['TZ']</code> for
|
67
|
+
<p>Handle time with zone without ActiveSupport, or <code>ENV['TZ']</code> for
|
68
68
|
thread-safety.</p>
|
69
69
|
|
70
70
|
<h2 id="label-Installation">Installation</h2>
|
@@ -84,8 +84,65 @@ thread-safety.</p>
|
|
84
84
|
|
85
85
|
<h2 id="label-Usage">Usage</h2>
|
86
86
|
|
87
|
+
<p>Assume your localtime zone is <code>+09:00</code>
|
88
|
+
(<code>Asia/Tokyo</code>):</p>
|
89
|
+
|
90
|
+
<pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_require'>require</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>time</span><span class='tstring_end'>'</span></span>
|
91
|
+
|
92
|
+
<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'>'</span><span class='tstring_content'>2015-01-01</span><span class='tstring_end'>'</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>%Y-%m-%d</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span>
|
93
|
+
<span class='comment'>#=> 2015-01-01 00:00:00 +0900
|
94
|
+
</span></code></pre>
|
95
|
+
|
96
|
+
<p>But, you want to get time in <code>+08:00</code> (<code>Asia/Taipei</code>)
|
97
|
+
as <code>2015-01-01 00:00:00 +0800</code>.</p>
|
98
|
+
|
99
|
+
<p>If the timezone format is in numeric formats such as
|
100
|
+
<code>[+-]HH:MM</code>, <code>[+-]HHMM</code>, <code>[+-]HH</code>, you may
|
101
|
+
use <code>%z</code> of strptime:</p>
|
102
|
+
|
103
|
+
<pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_require'>require</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>time</span><span class='tstring_end'>'</span></span>
|
104
|
+
|
105
|
+
<span class='id identifier rubyid_date'>date</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>2015-01-01</span><span class='tstring_end'>'</span></span>
|
106
|
+
<span class='id identifier rubyid_timezone'>timezone</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>+08:00</span><span class='tstring_end'>'</span></span>
|
107
|
+
<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'>"</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_date'>date</span><span class='embexpr_end'>}</span><span class='tstring_content'> </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_timezone'>timezone</span><span class='embexpr_end'>}</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>%Y-%m-%d %z</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span>
|
108
|
+
<span class='comment'>#=> 2015-01-01 00:00:00 +0800
|
109
|
+
</span></code></pre>
|
110
|
+
|
111
|
+
<p>However, if the timezone format is in the <code>Region/Zone</code> format
|
112
|
+
such as <code>Asia/Taipei</code>, <code>%Z</code> or <code>%z</code>
|
113
|
+
won't work. So, use <code>time_with_zone</code> gem as:</p>
|
114
|
+
|
115
|
+
<pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_require'>require</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>time_with_zone</span><span class='tstring_end'>'</span></span>
|
116
|
+
|
117
|
+
<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'>'</span><span class='tstring_content'>2015-01-01</span><span class='tstring_end'>'</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>%Y-%m-%d</span><span class='tstring_end'>'</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>Asia/Taipei</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span>
|
118
|
+
<span class='comment'>#=> 2015-01-01 00:00:00 +0800
|
119
|
+
</span></code></pre>
|
120
|
+
|
121
|
+
<p>TimeWithZone gem accepts numeric formats, and the <code>Region/Zone</code>
|
122
|
+
format, and some of short-abbreviations of timezone such as UTC.</p>
|
123
|
+
|
124
|
+
<h2 id="label-Documents">Documents</h2>
|
125
|
+
|
126
|
+
<p>Available methods are:</p>
|
127
|
+
<ul><li>
|
128
|
+
<p>strptime_with_zone(str, format, timezone)</p>
|
129
|
+
</li><li>
|
130
|
+
<p>parse_with_zone(str, timezone)</p>
|
131
|
+
</li><li>
|
132
|
+
<p>set_zone(time, timezone)</p>
|
133
|
+
</li><li>
|
134
|
+
<p>zone_offset(timezone, time = nil)</p>
|
135
|
+
</li><li>
|
136
|
+
<p>strptime_with_zone_offset(str, format, zone_offset)</p>
|
137
|
+
</li><li>
|
138
|
+
<p>parse_with_zone_offset(str, zone_offset)</p>
|
139
|
+
</li><li>
|
140
|
+
<p>set_zone_offset(time, zone_offset)</p>
|
141
|
+
</li></ul>
|
142
|
+
|
87
143
|
<p>See <a
|
88
|
-
href="https://sonots.github.io/time_with_zone/TimeWithZone.html">docs</a
|
144
|
+
href="https://sonots.github.io/time_with_zone/TimeWithZone.html">docs</a>
|
145
|
+
for details</p>
|
89
146
|
|
90
147
|
<h2 id="label-Development">Development</h2>
|
91
148
|
|
@@ -124,7 +181,7 @@ href="http://opensource.org/licenses/MIT">MIT License</a>.</p>
|
|
124
181
|
</div></div>
|
125
182
|
|
126
183
|
<div id="footer">
|
127
|
-
Generated on Mon Oct 31
|
184
|
+
Generated on Mon Oct 31 21:29:31 2016 by
|
128
185
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
129
186
|
0.8.7.6 (ruby-2.3.0).
|
130
187
|
</div>
|
data/docs/index.html
CHANGED
@@ -64,7 +64,7 @@
|
|
64
64
|
<div id="content"><div id='filecontents'>
|
65
65
|
<h1 id="label-TimeWithZone">TimeWithZone</h1>
|
66
66
|
|
67
|
-
<p>Handle time with zone without ActiveSupport or <code>ENV['TZ']</code> for
|
67
|
+
<p>Handle time with zone without ActiveSupport, or <code>ENV['TZ']</code> for
|
68
68
|
thread-safety.</p>
|
69
69
|
|
70
70
|
<h2 id="label-Installation">Installation</h2>
|
@@ -84,8 +84,65 @@ thread-safety.</p>
|
|
84
84
|
|
85
85
|
<h2 id="label-Usage">Usage</h2>
|
86
86
|
|
87
|
+
<p>Assume your localtime zone is <code>+09:00</code>
|
88
|
+
(<code>Asia/Tokyo</code>):</p>
|
89
|
+
|
90
|
+
<pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_require'>require</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>time</span><span class='tstring_end'>'</span></span>
|
91
|
+
|
92
|
+
<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'>'</span><span class='tstring_content'>2015-01-01</span><span class='tstring_end'>'</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>%Y-%m-%d</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span>
|
93
|
+
<span class='comment'>#=> 2015-01-01 00:00:00 +0900
|
94
|
+
</span></code></pre>
|
95
|
+
|
96
|
+
<p>But, you want to get time in <code>+08:00</code> (<code>Asia/Taipei</code>)
|
97
|
+
as <code>2015-01-01 00:00:00 +0800</code>.</p>
|
98
|
+
|
99
|
+
<p>If the timezone format is in numeric formats such as
|
100
|
+
<code>[+-]HH:MM</code>, <code>[+-]HHMM</code>, <code>[+-]HH</code>, you may
|
101
|
+
use <code>%z</code> of strptime:</p>
|
102
|
+
|
103
|
+
<pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_require'>require</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>time</span><span class='tstring_end'>'</span></span>
|
104
|
+
|
105
|
+
<span class='id identifier rubyid_date'>date</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>2015-01-01</span><span class='tstring_end'>'</span></span>
|
106
|
+
<span class='id identifier rubyid_timezone'>timezone</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>+08:00</span><span class='tstring_end'>'</span></span>
|
107
|
+
<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'>"</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_date'>date</span><span class='embexpr_end'>}</span><span class='tstring_content'> </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_timezone'>timezone</span><span class='embexpr_end'>}</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>%Y-%m-%d %z</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span>
|
108
|
+
<span class='comment'>#=> 2015-01-01 00:00:00 +0800
|
109
|
+
</span></code></pre>
|
110
|
+
|
111
|
+
<p>However, if the timezone format is in the <code>Region/Zone</code> format
|
112
|
+
such as <code>Asia/Taipei</code>, <code>%Z</code> or <code>%z</code>
|
113
|
+
won't work. So, use <code>time_with_zone</code> gem as:</p>
|
114
|
+
|
115
|
+
<pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_require'>require</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>time_with_zone</span><span class='tstring_end'>'</span></span>
|
116
|
+
|
117
|
+
<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'>'</span><span class='tstring_content'>2015-01-01</span><span class='tstring_end'>'</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>%Y-%m-%d</span><span class='tstring_end'>'</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>Asia/Taipei</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span>
|
118
|
+
<span class='comment'>#=> 2015-01-01 00:00:00 +0800
|
119
|
+
</span></code></pre>
|
120
|
+
|
121
|
+
<p>TimeWithZone gem accepts numeric formats, and the <code>Region/Zone</code>
|
122
|
+
format, and some of short-abbreviations of timezone such as UTC.</p>
|
123
|
+
|
124
|
+
<h2 id="label-Documents">Documents</h2>
|
125
|
+
|
126
|
+
<p>Available methods are:</p>
|
127
|
+
<ul><li>
|
128
|
+
<p>strptime_with_zone(str, format, timezone)</p>
|
129
|
+
</li><li>
|
130
|
+
<p>parse_with_zone(str, timezone)</p>
|
131
|
+
</li><li>
|
132
|
+
<p>set_zone(time, timezone)</p>
|
133
|
+
</li><li>
|
134
|
+
<p>zone_offset(timezone, time = nil)</p>
|
135
|
+
</li><li>
|
136
|
+
<p>strptime_with_zone_offset(str, format, zone_offset)</p>
|
137
|
+
</li><li>
|
138
|
+
<p>parse_with_zone_offset(str, zone_offset)</p>
|
139
|
+
</li><li>
|
140
|
+
<p>set_zone_offset(time, zone_offset)</p>
|
141
|
+
</li></ul>
|
142
|
+
|
87
143
|
<p>See <a
|
88
|
-
href="https://sonots.github.io/time_with_zone/TimeWithZone.html">docs</a
|
144
|
+
href="https://sonots.github.io/time_with_zone/TimeWithZone.html">docs</a>
|
145
|
+
for details</p>
|
89
146
|
|
90
147
|
<h2 id="label-Development">Development</h2>
|
91
148
|
|
@@ -124,7 +181,7 @@ href="http://opensource.org/licenses/MIT">MIT License</a>.</p>
|
|
124
181
|
</div></div>
|
125
182
|
|
126
183
|
<div id="footer">
|
127
|
-
Generated on Mon Oct 31
|
184
|
+
Generated on Mon Oct 31 21:29:31 2016 by
|
128
185
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
129
186
|
0.8.7.6 (ruby-2.3.0).
|
130
187
|
</div>
|
data/docs/method_list.html
CHANGED
@@ -70,23 +70,35 @@
|
|
70
70
|
|
71
71
|
|
72
72
|
<li class="r2 ">
|
73
|
-
<span class='object_link'><a href="TimeWithZone.html#
|
73
|
+
<span class='object_link'><a href="TimeWithZone.html#parse_with_zone_offset-class_method" title="TimeWithZone.parse_with_zone_offset (method)">parse_with_zone_offset</a></span>
|
74
74
|
<small>TimeWithZone</small>
|
75
75
|
</li>
|
76
76
|
|
77
77
|
|
78
78
|
<li class="r1 ">
|
79
|
-
<span class='object_link'><a href="TimeWithZone.html#
|
79
|
+
<span class='object_link'><a href="TimeWithZone.html#set_zone-class_method" title="TimeWithZone.set_zone (method)">set_zone</a></span>
|
80
80
|
<small>TimeWithZone</small>
|
81
81
|
</li>
|
82
82
|
|
83
83
|
|
84
84
|
<li class="r2 ">
|
85
|
+
<span class='object_link'><a href="TimeWithZone.html#set_zone_offset-class_method" title="TimeWithZone.set_zone_offset (method)">set_zone_offset</a></span>
|
86
|
+
<small>TimeWithZone</small>
|
87
|
+
</li>
|
88
|
+
|
89
|
+
|
90
|
+
<li class="r1 ">
|
85
91
|
<span class='object_link'><a href="TimeWithZone.html#strptime_with_zone-class_method" title="TimeWithZone.strptime_with_zone (method)">strptime_with_zone</a></span>
|
86
92
|
<small>TimeWithZone</small>
|
87
93
|
</li>
|
88
94
|
|
89
95
|
|
96
|
+
<li class="r2 ">
|
97
|
+
<span class='object_link'><a href="TimeWithZone.html#strptime_with_zone_offset-class_method" title="TimeWithZone.strptime_with_zone_offset (method)">strptime_with_zone_offset</a></span>
|
98
|
+
<small>TimeWithZone</small>
|
99
|
+
</li>
|
100
|
+
|
101
|
+
|
90
102
|
<li class="r1 ">
|
91
103
|
<span class='object_link'><a href="TimeWithZone.html#zone_offset-class_method" title="TimeWithZone.zone_offset (method)">zone_offset</a></span>
|
92
104
|
<small>TimeWithZone</small>
|
@@ -103,7 +103,7 @@
|
|
103
103
|
</div>
|
104
104
|
|
105
105
|
<div id="footer">
|
106
|
-
Generated on Mon Oct 31
|
106
|
+
Generated on Mon Oct 31 21:29:31 2016 by
|
107
107
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
108
108
|
0.8.7.6 (ruby-2.3.0).
|
109
109
|
</div>
|
data/lib/time_with_zone.rb
CHANGED
@@ -60,7 +60,7 @@ class TimeWithZone
|
|
60
60
|
# require 'time_with_zone'
|
61
61
|
# time = Time.parse("2016-10-20 00:00:00 +00:00")
|
62
62
|
#
|
63
|
-
# time.dup.localtime(TimeWithZone.zone_offset("Asia/Taipei"))
|
63
|
+
# time.dup.localtime(TimeWithZone.zone_offset("Asia/Taipei", time))
|
64
64
|
# #=> 2010-10-20 08:00:00 +0800
|
65
65
|
#
|
66
66
|
# @param [Time] time object
|
@@ -113,6 +113,22 @@ class TimeWithZone
|
|
113
113
|
set_zone!(time, timezone)
|
114
114
|
end
|
115
115
|
|
116
|
+
# Time.parse with zone_offset
|
117
|
+
#
|
118
|
+
# require 'time_with_zone'
|
119
|
+
#
|
120
|
+
# TimeWithZone.parse_with_zone_offset("2016-10-20", 28800)
|
121
|
+
# #=> 2016-10-20 00:00:00 +0800
|
122
|
+
#
|
123
|
+
# @param [String] date string to be parsed
|
124
|
+
# @param [Integer] zone_offset
|
125
|
+
# @return [Time]
|
126
|
+
def self.parse_with_zone_offset(date, zone_offset)
|
127
|
+
time = Time.parse(date)
|
128
|
+
set_zone_offset!(time, zone_offset)
|
129
|
+
end
|
130
|
+
|
131
|
+
|
116
132
|
# Time.strptime with timezone
|
117
133
|
#
|
118
134
|
# ENV['TZ'] = '+09:00' # Assume your local timezone is +09:00
|
@@ -146,6 +162,22 @@ class TimeWithZone
|
|
146
162
|
set_zone!(time, timezone)
|
147
163
|
end
|
148
164
|
|
165
|
+
# Time.strptime with zone_offset
|
166
|
+
#
|
167
|
+
# require 'time_with_zone'
|
168
|
+
#
|
169
|
+
# TimeWithZone.strptime_with_zone_offset("2016-10-20", "%Y-%m-%d", 28800)
|
170
|
+
# #=> 2016-10-20 00:00:00 +0800
|
171
|
+
#
|
172
|
+
# @param [String] date string to be parsed
|
173
|
+
# @param [String] format
|
174
|
+
# @param [Integer] zone_offset
|
175
|
+
# @return [Time]
|
176
|
+
def self.strptime_with_zone_offset(date, format, zone_offset)
|
177
|
+
time = Time.strptime(date, format)
|
178
|
+
set_zone_offset!(time, zone_offset)
|
179
|
+
end
|
180
|
+
|
149
181
|
# This method changes only the zone field of Time object
|
150
182
|
#
|
151
183
|
# require 'time_with_zone'
|