time_with_zone 0.2.1 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fd91409d0be8be98807e79978b9f780b66378169
4
- data.tar.gz: 5eff3854aff0288ed5c53468284015e1ade975c4
3
+ metadata.gz: b7a1d893be0b23feef4936ea5dee2de6fa40a376
4
+ data.tar.gz: 72a694c5dc1538f73a7a16509860858dbfd028cc
5
5
  SHA512:
6
- metadata.gz: 66304bd2be5721f7698854f4682de8b94aa54277562dd3f1a94494ca79deccf8e9888291ad7b5b708ca9ffe8c8592e6b5c720709b2bb2b592d91d1b8cb3e1ab7
7
- data.tar.gz: 72a63b6d9fa9986f66d37787f6916b573a02d8d211ab2f6de41519d3a2441746cc1f6aeebe3fb6e9da4803ae1b8e71caa4ef5165492235e5e244780564bf969b
6
+ metadata.gz: 42d2430505f2c2433b0d82430def19df46da362df2daff2771f5e1abd2db536e52551dab5f5187471d9427776ff3a4e87656292f0fe27d87f80dead6bd1c7e54
7
+ data.tar.gz: eaea6e110b6b65dfc60fb90a51d71cca987d0768f653c2b791b98ccb1d7627cfeb298d040a4a4252d20176d3680b732208b5c50e938ce2d87014a7e516d7db77
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ # 0.3.0 (2016-10-31)
2
+
3
+ Changes:
4
+
5
+ * Make set_zone! and set_zone_offset! be private
6
+
1
7
  # 0.2.1 (2016-10-31)
2
8
 
3
9
  Enhancements:
@@ -6,7 +12,7 @@ Enhancements:
6
12
 
7
13
  # 0.2.0 (2016-10-31)
8
14
 
9
- Incompatibility changes:
15
+ Changes:
10
16
 
11
17
  * Rename TimeWithZone.overwrite_zone to TimeWithZone.set_zone
12
18
 
@@ -115,7 +115,7 @@
115
115
  <span class='comment'># =&gt; &#39;2016-10-10 00:00:00 +0800&#39;
116
116
  </span>
117
117
  <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'>&#39;</span><span class='tstring_content'>2016-10-10 00:00:00 +00:00</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span>
118
- <span class='const'>TimeWithZone</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='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>Asia/Taipei</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span>
118
+ <span class='const'>TimeWithZone</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='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>Asia/Taipei</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span>
119
119
  <span class='comment'># =&gt; &#39;2016-10-10 00:00:00 +0800&#39;
120
120
  </span>
121
121
  <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'>&#39;</span><span class='tstring_content'>2016-10-10 00:00:00 +00:00</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span>
@@ -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'>&quot;</span><span class='tstring_content'>0.2.0</span><span class='tstring_end'>&quot;</span></span></pre></dd>
195
+ <dd><pre class="code"><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>0.2.1</span><span class='tstring_end'>&quot;</span></span></pre></dd>
196
196
 
197
197
  </dl>
198
198
 
@@ -214,7 +214,7 @@
214
214
  <li class="public ">
215
215
  <span class="summary_signature">
216
216
 
217
- <a href="#localtime_with_zone-class_method" title="localtime_with_zone (class method)">+ (Object) <strong>localtime_with_zone</strong>(time, timezone) </a>
217
+ <a href="#localtime_with_zone-class_method" title="localtime_with_zone (class method)">+ (Time) <strong>localtime_with_zone</strong>(time, timezone) </a>
218
218
 
219
219
 
220
220
 
@@ -238,7 +238,7 @@
238
238
  <li class="public ">
239
239
  <span class="summary_signature">
240
240
 
241
- <a href="#localtime_with_zone%21-class_method" title="localtime_with_zone! (class method)">+ (Object) <strong>localtime_with_zone!</strong>(time, timezone) </a>
241
+ <a href="#localtime_with_zone%21-class_method" title="localtime_with_zone! (class method)">+ (Time) <strong>localtime_with_zone!</strong>(time, timezone) </a>
242
242
 
243
243
 
244
244
 
@@ -262,7 +262,7 @@
262
262
  <li class="public ">
263
263
  <span class="summary_signature">
264
264
 
265
- <a href="#parse_with_zone-class_method" title="parse_with_zone (class method)">+ (Object) <strong>parse_with_zone</strong>(date, timezone) </a>
265
+ <a href="#parse_with_zone-class_method" title="parse_with_zone (class method)">+ (Time) <strong>parse_with_zone</strong>(date, timezone) </a>
266
266
 
267
267
 
268
268
 
@@ -301,7 +301,7 @@
301
301
 
302
302
 
303
303
  <span class="summary_desc"><div class='inline'>
304
- <p>This method simply sets the zone field of Time object (non-destructive).</p>
304
+ <p>This method changes only the zone field of Time object.</p>
305
305
  </div></span>
306
306
 
307
307
  </li>
@@ -310,7 +310,7 @@
310
310
  <li class="public ">
311
311
  <span class="summary_signature">
312
312
 
313
- <a href="#set_zone%21-class_method" title="set_zone! (class method)">+ (Object) <strong>set_zone!</strong>(time, timezone) </a>
313
+ <a href="#set_zone_offset-class_method" title="set_zone_offset (class method)">+ (Time) <strong>set_zone_offset</strong>(time, zone_offset) </a>
314
314
 
315
315
 
316
316
 
@@ -325,7 +325,7 @@
325
325
 
326
326
 
327
327
  <span class="summary_desc"><div class='inline'>
328
- <p>This method simply sets the zone field of Time object (destructive).</p>
328
+ <p>This method changes only the zone offset field of Time object.</p>
329
329
  </div></span>
330
330
 
331
331
  </li>
@@ -334,7 +334,7 @@
334
334
  <li class="public ">
335
335
  <span class="summary_signature">
336
336
 
337
- <a href="#strptime_with_zone-class_method" title="strptime_with_zone (class method)">+ (Object) <strong>strptime_with_zone</strong>(date, format, timezone) </a>
337
+ <a href="#strptime_with_zone-class_method" title="strptime_with_zone (class method)">+ (Time) <strong>strptime_with_zone</strong>(date, format, timezone) </a>
338
338
 
339
339
 
340
340
 
@@ -391,7 +391,7 @@
391
391
  <div class="method_details first">
392
392
  <h3 class="signature first" id="localtime_with_zone-class_method">
393
393
 
394
- + (<tt>Object</tt>) <strong>localtime_with_zone</strong>(time, timezone)
394
+ + (<tt>Time</tt>) <strong>localtime_with_zone</strong>(time, timezone)
395
395
 
396
396
 
397
397
 
@@ -473,10 +473,13 @@
473
473
 
474
474
  </li>
475
475
 
476
+ </ul>
477
+
478
+ <p class="tag_title">Returns:</p>
479
+ <ul class="return">
480
+
476
481
  <li>
477
482
 
478
- <span class='name'></span>
479
-
480
483
 
481
484
  <span class='type'>(<tt>Time</tt>)</span>
482
485
 
@@ -486,7 +489,6 @@
486
489
 
487
490
  </ul>
488
491
 
489
-
490
492
  </div><table class="source_code">
491
493
  <tr>
492
494
  <td>
@@ -511,7 +513,7 @@
511
513
  <div class="method_details ">
512
514
  <h3 class="signature " id="localtime_with_zone!-class_method">
513
515
 
514
- + (<tt>Object</tt>) <strong>localtime_with_zone!</strong>(time, timezone)
516
+ + (<tt>Time</tt>) <strong>localtime_with_zone!</strong>(time, timezone)
515
517
 
516
518
 
517
519
 
@@ -563,6 +565,19 @@
563
565
 
564
566
  </ul>
565
567
 
568
+ <p class="tag_title">Returns:</p>
569
+ <ul class="return">
570
+
571
+ <li>
572
+
573
+
574
+ <span class='type'>(<tt>Time</tt>)</span>
575
+
576
+
577
+
578
+ </li>
579
+
580
+ </ul>
566
581
 
567
582
  <p class="tag_title">See Also:</p>
568
583
  <ul class="see">
@@ -577,13 +592,13 @@
577
592
  <pre class="lines">
578
593
 
579
594
 
580
- 78
581
595
  79
582
596
  80
583
- 81</pre>
597
+ 81
598
+ 82</pre>
584
599
  </td>
585
600
  <td>
586
- <pre class="code"><span class="info file"># File 'lib/time_with_zone.rb', line 78</span>
601
+ <pre class="code"><span class="info file"># File 'lib/time_with_zone.rb', line 79</span>
587
602
 
588
603
  <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>
589
604
  <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>
@@ -597,7 +612,7 @@
597
612
  <div class="method_details ">
598
613
  <h3 class="signature " id="parse_with_zone-class_method">
599
614
 
600
- + (<tt>Object</tt>) <strong>parse_with_zone</strong>(date, timezone)
615
+ + (<tt>Time</tt>) <strong>parse_with_zone</strong>(date, timezone)
601
616
 
602
617
 
603
618
 
@@ -672,6 +687,19 @@
672
687
 
673
688
  </ul>
674
689
 
690
+ <p class="tag_title">Returns:</p>
691
+ <ul class="return">
692
+
693
+ <li>
694
+
695
+
696
+ <span class='type'>(<tt>Time</tt>)</span>
697
+
698
+
699
+
700
+ </li>
701
+
702
+ </ul>
675
703
 
676
704
  </div><table class="source_code">
677
705
  <tr>
@@ -679,13 +707,13 @@
679
707
  <pre class="lines">
680
708
 
681
709
 
682
- 109
683
- 110
684
710
  111
685
- 112</pre>
711
+ 112
712
+ 113
713
+ 114</pre>
686
714
  </td>
687
715
  <td>
688
- <pre class="code"><span class="info file"># File 'lib/time_with_zone.rb', line 109</span>
716
+ <pre class="code"><span class="info file"># File 'lib/time_with_zone.rb', line 111</span>
689
717
 
690
718
  <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>
691
719
  <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>
@@ -708,7 +736,7 @@
708
736
  </h3><div class="docstring">
709
737
  <div class="discussion">
710
738
 
711
- <p>This method simply sets the zone field of Time object (non-destructive)</p>
739
+ <p>This method changes only the zone field of Time object</p>
712
740
 
713
741
  <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>
714
742
 
@@ -769,12 +797,12 @@
769
797
  <pre class="lines">
770
798
 
771
799
 
772
- 158
773
- 159
774
- 160</pre>
800
+ 161
801
+ 162
802
+ 163</pre>
775
803
  </td>
776
804
  <td>
777
- <pre class="code"><span class="info file"># File 'lib/time_with_zone.rb', line 158</span>
805
+ <pre class="code"><span class="info file"># File 'lib/time_with_zone.rb', line 161</span>
778
806
 
779
807
  <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>
780
808
  <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>
@@ -785,9 +813,9 @@
785
813
  </div>
786
814
 
787
815
  <div class="method_details ">
788
- <h3 class="signature " id="set_zone!-class_method">
816
+ <h3 class="signature " id="set_zone_offset-class_method">
789
817
 
790
- + (<tt>Object</tt>) <strong>set_zone!</strong>(time, timezone)
818
+ + (<tt>Time</tt>) <strong>set_zone_offset</strong>(time, zone_offset)
791
819
 
792
820
 
793
821
 
@@ -796,7 +824,15 @@
796
824
  </h3><div class="docstring">
797
825
  <div class="discussion">
798
826
 
799
- <p>This method simply sets the zone field of Time object (destructive)</p>
827
+ <p>This method changes only the zone offset field of Time object</p>
828
+
829
+ <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>
830
+ <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-02-02 00:00:00 +00:00</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
831
+
832
+ <span class='const'>TimeWithZone</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='int'>28800</span><span class='rparen'>)</span>
833
+ <span class='comment'>#=&gt; &quot;2016-02-02 00:00:00 +0800&quot;
834
+ </span><span class='comment'># Note that it is not &quot;2016-02-02 08:00:00 +0800&quot; like Time#localtime(zone_offset)
835
+ </span></code></pre>
800
836
 
801
837
 
802
838
  </div>
@@ -818,10 +854,10 @@
818
854
 
819
855
  <li>
820
856
 
821
- <span class='name'>timezone</span>
857
+ <span class='name'>zone_offset</span>
822
858
 
823
859
 
824
- <span class='type'>(<tt>String</tt>)</span>
860
+ <span class='type'>(<tt>Integer</tt>)</span>
825
861
 
826
862
 
827
863
 
@@ -829,13 +865,19 @@
829
865
 
830
866
  </ul>
831
867
 
832
-
833
- <p class="tag_title">See Also:</p>
834
- <ul class="see">
835
-
836
- <li><span class='object_link'><a href="#set_zone-class_method" title="TimeWithZone.set_zone (method)">set_zone</a></span></li>
837
-
838
- </ul>
868
+ <p class="tag_title">Returns:</p>
869
+ <ul class="return">
870
+
871
+ <li>
872
+
873
+
874
+ <span class='type'>(<tt>Time</tt>)</span>
875
+
876
+
877
+
878
+ </li>
879
+
880
+ </ul>
839
881
 
840
882
  </div><table class="source_code">
841
883
  <tr>
@@ -843,19 +885,15 @@
843
885
  <pre class="lines">
844
886
 
845
887
 
846
- 167
847
- 168
848
- 169
849
- 170
850
- 171</pre>
888
+ 177
889
+ 178
890
+ 179</pre>
851
891
  </td>
852
892
  <td>
853
- <pre class="code"><span class="info file"># File 'lib/time_with_zone.rb', line 167</span>
893
+ <pre class="code"><span class="info file"># File 'lib/time_with_zone.rb', line 177</span>
854
894
 
855
- <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>
856
- <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>
857
- <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>
858
- <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>
895
+ <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
+ <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>
859
897
  <span class='kw'>end</span></pre>
860
898
  </td>
861
899
  </tr>
@@ -865,7 +903,7 @@
865
903
  <div class="method_details ">
866
904
  <h3 class="signature " id="strptime_with_zone-class_method">
867
905
 
868
- + (<tt>Object</tt>) <strong>strptime_with_zone</strong>(date, format, timezone)
906
+ + (<tt>Time</tt>) <strong>strptime_with_zone</strong>(date, format, timezone)
869
907
 
870
908
 
871
909
 
@@ -951,6 +989,19 @@
951
989
 
952
990
  </ul>
953
991
 
992
+ <p class="tag_title">Returns:</p>
993
+ <ul class="return">
994
+
995
+ <li>
996
+
997
+
998
+ <span class='type'>(<tt>Time</tt>)</span>
999
+
1000
+
1001
+
1002
+ </li>
1003
+
1004
+ </ul>
954
1005
 
955
1006
  </div><table class="source_code">
956
1007
  <tr>
@@ -958,13 +1009,13 @@
958
1009
  <pre class="lines">
959
1010
 
960
1011
 
961
- 141
962
- 142
963
- 143
964
- 144</pre>
1012
+ 144
1013
+ 145
1014
+ 146
1015
+ 147</pre>
965
1016
  </td>
966
1017
  <td>
967
- <pre class="code"><span class="info file"># File 'lib/time_with_zone.rb', line 141</span>
1018
+ <pre class="code"><span class="info file"># File 'lib/time_with_zone.rb', line 144</span>
968
1019
 
969
1020
  <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>
970
1021
  <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>
@@ -1073,14 +1124,6 @@
1073
1124
  <pre class="lines">
1074
1125
 
1075
1126
 
1076
- 193
1077
- 194
1078
- 195
1079
- 196
1080
- 197
1081
- 198
1082
- 199
1083
- 200
1084
1127
  201
1085
1128
  202
1086
1129
  203
@@ -1088,10 +1131,18 @@
1088
1131
  205
1089
1132
  206
1090
1133
  207
1091
- 208</pre>
1134
+ 208
1135
+ 209
1136
+ 210
1137
+ 211
1138
+ 212
1139
+ 213
1140
+ 214
1141
+ 215
1142
+ 216</pre>
1092
1143
  </td>
1093
1144
  <td>
1094
- <pre class="code"><span class="info file"># File 'lib/time_with_zone.rb', line 193</span>
1145
+ <pre class="code"><span class="info file"># File 'lib/time_with_zone.rb', line 201</span>
1095
1146
 
1096
1147
  <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>
1097
1148
  <span class='kw'>if</span> <span class='const'>NUMERIC_PATTERN</span> <span class='op'>===</span> <span class='id identifier rubyid_timezone'>timezone</span>
@@ -1119,7 +1170,7 @@
1119
1170
  </div>
1120
1171
 
1121
1172
  <div id="footer">
1122
- Generated on Mon Oct 31 12:59:31 2016 by
1173
+ Generated on Mon Oct 31 19:57:03 2016 by
1123
1174
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
1124
1175
  0.8.7.6 (ruby-2.3.0).
1125
1176
  </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 12:59:30 2016 by
107
+ Generated on Mon Oct 31 19:57:03 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>
@@ -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 &quot;Software&quot;), 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 &quot;AS IS&quot;, 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 12:59:31 2016 by
67
+ Generated on Mon Oct 31 19:57:03 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>
@@ -124,7 +124,7 @@ href="http://opensource.org/licenses/MIT">MIT License</a>.</p>
124
124
  </div></div>
125
125
 
126
126
  <div id="footer">
127
- Generated on Mon Oct 31 12:59:31 2016 by
127
+ Generated on Mon Oct 31 19:57:03 2016 by
128
128
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
129
129
  0.8.7.6 (ruby-2.3.0).
130
130
  </div>
data/docs/index.html CHANGED
@@ -124,7 +124,7 @@ href="http://opensource.org/licenses/MIT">MIT License</a>.</p>
124
124
  </div></div>
125
125
 
126
126
  <div id="footer">
127
- Generated on Mon Oct 31 12:59:31 2016 by
127
+ Generated on Mon Oct 31 19:57:03 2016 by
128
128
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
129
129
  0.8.7.6 (ruby-2.3.0).
130
130
  </div>
@@ -76,7 +76,7 @@
76
76
 
77
77
 
78
78
  <li class="r1 ">
79
- <span class='object_link'><a href="TimeWithZone.html#set_zone%21-class_method" title="TimeWithZone.set_zone! (method)">set_zone!</a></span>
79
+ <span class='object_link'><a href="TimeWithZone.html#set_zone_offset-class_method" title="TimeWithZone.set_zone_offset (method)">set_zone_offset</a></span>
80
80
  <small>TimeWithZone</small>
81
81
  </li>
82
82
 
@@ -103,7 +103,7 @@
103
103
  </div>
104
104
 
105
105
  <div id="footer">
106
- Generated on Mon Oct 31 12:59:31 2016 by
106
+ Generated on Mon Oct 31 19:57:03 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>
@@ -13,7 +13,7 @@ require 'tzinfo'
13
13
  # # => '2016-10-10 00:00:00 +0800'
14
14
  #
15
15
  # time = Time.parse('2016-10-10 00:00:00 +00:00')
16
- # TimeWithZone.set_zone!(time, 'Asia/Taipei')
16
+ # TimeWithZone.set_zone(time, 'Asia/Taipei')
17
17
  # # => '2016-10-10 00:00:00 +0800'
18
18
  #
19
19
  # time = Time.parse('2016-10-10 00:00:00 +00:00')
@@ -65,7 +65,7 @@ class TimeWithZone
65
65
  #
66
66
  # @param [Time] time object
67
67
  # @param [String] timezone {NUMERIC_PATTERN} or {NAME_PATTERN} or {ZoneOffset}
68
- # @param [Time]
68
+ # @return [Time]
69
69
  def self.localtime_with_zone(time, timezone)
70
70
  localtime_with_zone!(time.dup, timezone)
71
71
  end
@@ -74,6 +74,7 @@ class TimeWithZone
74
74
  #
75
75
  # @param [Time] time object
76
76
  # @param [String] timezone {NUMERIC_PATTERN} or {NAME_PATTERN} or {ZoneOffset}
77
+ # @return [Time]
77
78
  # @see localtime_with_zone
78
79
  def self.localtime_with_zone!(time, timezone)
79
80
  _zone_offset = zone_offset(timezone, time)
@@ -106,6 +107,7 @@ class TimeWithZone
106
107
  #
107
108
  # @param [String] date string to be parsed
108
109
  # @param [String] timezone {NUMERIC_PATTERN} or {NAME_PATTERN} or {ZoneOffset}
110
+ # @return [Time]
109
111
  def self.parse_with_zone(date, timezone)
110
112
  time = Time.parse(date)
111
113
  set_zone!(time, timezone)
@@ -138,12 +140,13 @@ class TimeWithZone
138
140
  # @param [String] date string to be parsed
139
141
  # @param [String] format
140
142
  # @param [String] timezone {NUMERIC_PATTERN} or {NAME_PATTERN} or {ZoneOffset}
143
+ # @return [Time]
141
144
  def self.strptime_with_zone(date, format, timezone)
142
145
  time = Time.strptime(date, format)
143
146
  set_zone!(time, timezone)
144
147
  end
145
148
 
146
- # This method simply sets the zone field of Time object (non-destructive)
149
+ # This method changes only the zone field of Time object
147
150
  #
148
151
  # require 'time_with_zone'
149
152
  #
@@ -159,16 +162,7 @@ class TimeWithZone
159
162
  set_zone!(time.dup, timezone)
160
163
  end
161
164
 
162
- # This method simply sets the zone field of Time object (destructive)
163
- #
164
- # @param [Time] time
165
- # @param [String] timezone
166
- # @see set_zone
167
- def self.set_zone!(time, timezone)
168
- set_zone_offset!(time, zone_offset(timezone, time))
169
- end
170
-
171
- # This method simply sets the zone offset field of Time object (non-destructive)
165
+ # This method changes only the zone offset field of Time object
172
166
  #
173
167
  # require 'time_with_zone'
174
168
  # time = Time.parse("2016-02-02 00:00:00 +00:00")
@@ -184,16 +178,6 @@ class TimeWithZone
184
178
  set_zone_offset!(time.dup, zone_offset)
185
179
  end
186
180
 
187
- # This method simply sets the zone offset field of Time object (destructive)
188
- #
189
- # @param [Time] time
190
- # @param [Integer] zone_offset
191
- # @see set_zone_offset
192
- def self.set_zone_offset!(time, zone_offset)
193
- utc_offset = time.utc_offset
194
- time.localtime(zone_offset) + utc_offset - zone_offset
195
- end
196
-
197
181
  # Returns zone offset for given timezone string
198
182
  #
199
183
  # require 'time_with_zone'
@@ -230,4 +214,29 @@ class TimeWithZone
230
214
  raise ArgumentError, "timezone format is invalid: #{timezone}"
231
215
  end
232
216
  end
217
+
218
+ private
219
+
220
+ # This method changes only the zone field of Time object
221
+ #
222
+ # @param [Time] time
223
+ # @param [String] timezone
224
+ # @return [Time]
225
+ # @see set_zone
226
+ # @todo how to modify time object destructively?
227
+ def self.set_zone!(time, timezone)
228
+ set_zone_offset!(time, zone_offset(timezone, time))
229
+ end
230
+
231
+ # This method changes only the zone offset field of Time object
232
+ #
233
+ # @param [Time] time
234
+ # @param [Integer] zone_offset
235
+ # @return [Time]
236
+ # @see set_zone_offset
237
+ # @todo how to modify time object destructively?
238
+ def self.set_zone_offset!(time, zone_offset)
239
+ utc_offset = time.utc_offset
240
+ time.localtime(zone_offset) + utc_offset - zone_offset
241
+ end
233
242
  end
@@ -1,3 +1,3 @@
1
1
  class TimeWithZone
2
- VERSION = "0.2.1"
2
+ VERSION = "0.3.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: time_with_zone
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - sonots