doc/TaskJuggler/TjTime.html in taskjuggler-0.0.7 vs doc/TaskJuggler/TjTime.html in taskjuggler-0.0.8

- old
+ new

@@ -77,10 +77,12 @@ <li><a href="#method-c-new">::new</a></li> <li><a href="#method-c-now">::now</a></li> + <li><a href="#method-c-parse">::parse</a></li> + <li><a href="#method-i-%25">#%</a></li> <li><a href="#method-i-%2B">#+</a></li> <li><a href="#method-i--">#-</a></li> @@ -243,16 +245,22 @@ <li><a href="../TaskJuggler/ChargeSet.html">TaskJuggler::ChargeSet</a></li> <li><a href="../TaskJuggler/ChargeSetListAttribute.html">TaskJuggler::ChargeSetListAttribute</a></li> + <li><a href="../TaskJuggler/CollisionDetector.html">TaskJuggler::CollisionDetector</a></li> + <li><a href="../TaskJuggler/ColumnListAttribute.html">TaskJuggler::ColumnListAttribute</a></li> <li><a href="../TaskJuggler/ColumnTable.html">TaskJuggler::ColumnTable</a></li> <li><a href="../TaskJuggler/Daemon.html">TaskJuggler::Daemon</a></li> + <li><a href="../TaskJuggler/DataCache.html">TaskJuggler::DataCache</a></li> + + <li><a href="../TaskJuggler/DataCacheEntry.html">TaskJuggler::DataCacheEntry</a></li> + <li><a href="../TaskJuggler/DateAttribute.html">TaskJuggler::DateAttribute</a></li> <li><a href="../TaskJuggler/DefinitionListAttribute.html">TaskJuggler::DefinitionListAttribute</a></li> <li><a href="../TaskJuggler/DependencyListAttribute.html">TaskJuggler::DependencyListAttribute</a></li> @@ -355,11 +363,11 @@ <li><a href="../TaskJuggler/NikuResource.html">TaskJuggler::NikuResource</a></li> <li><a href="../TaskJuggler/NodeListAttribute.html">TaskJuggler::NodeListAttribute</a></li> - <li><a href="../TaskJuggler/OnShiftCache.html">TaskJuggler::OnShiftCache</a></li> + <li><a href="../TaskJuggler/PlaceHolderCell.html">TaskJuggler::PlaceHolderCell</a></li> <li><a href="../TaskJuggler/ProcessIntercom.html">TaskJuggler::ProcessIntercom</a></li> <li><a href="../TaskJuggler/ProcessIntercomIface.html">TaskJuggler::ProcessIntercomIface</a></li> @@ -535,10 +543,14 @@ <li><a href="../TaskJuggler/TextParser/Rule.html">TaskJuggler::TextParser::Rule</a></li> <li><a href="../TaskJuggler/TextParser/StackElement.html">TaskJuggler::TextParser::StackElement</a></li> + <li><a href="../TaskJuggler/TextParser/State.html">TaskJuggler::TextParser::State</a></li> + + <li><a href="../TaskJuggler/TextParser/StateTransition.html">TaskJuggler::TextParser::StateTransition</a></li> + <li><a href="../TaskJuggler/TextParser/TextParserResultArray.html">TaskJuggler::TextParser::TextParserResultArray</a></li> <li><a href="../TaskJuggler/TextParser/TokenDoc.html">TaskJuggler::TextParser::TokenDoc</a></li> <li><a href="../TaskJuggler/TextReport.html">TaskJuggler::TextReport</a></li> @@ -717,33 +729,37 @@ <div class="method-source-code" id="check-ime-one-source"> <pre> - <span class="ruby-comment cmt"># File lib/TjTime.rb, line 64</span> -64: <span class="ruby-keyword kw">def</span> <span class="ruby-constant">TjTime</span>.<span class="ruby-identifier">checkTimeZone</span>(<span class="ruby-identifier">zone</span>) -65: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">true</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">zone</span> <span class="ruby-operator">==</span> <span class="ruby-value str">'UTC'</span> -66: -67: <span class="ruby-comment cmt"># Valid time zones must be of the form 'Region/City'</span> -68: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">false</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">zone</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-value str">'/'</span>) -69: -70: <span class="ruby-comment cmt"># Save curent value of TZ</span> -71: <span class="ruby-identifier">tz</span> = <span class="ruby-constant">ENV</span>[<span class="ruby-value str">'TZ'</span>] -72: <span class="ruby-constant">ENV</span>[<span class="ruby-value str">'TZ'</span>] = <span class="ruby-identifier">zone</span> -73: <span class="ruby-identifier">newZone</span> = <span class="ruby-constant">Time</span>.<span class="ruby-identifier">new</span>.<span class="ruby-identifier">zone</span> -74: <span class="ruby-comment cmt"># If the time zone is valid, the OS can convert a zone like</span> -75: <span class="ruby-comment cmt"># 'America/Denver' into 'MST'. Unknown time zones are either not</span> -76: <span class="ruby-comment cmt"># converted or cause a fallback to UTC.</span> -77: <span class="ruby-comment cmt"># Since glibc 2.10 Time.new.zone only return the region for illegal</span> -78: <span class="ruby-comment cmt"># zones instead of the full zone string like it does on earlier</span> -79: <span class="ruby-comment cmt"># versions.</span> -80: <span class="ruby-identifier">region</span> = <span class="ruby-identifier">zone</span>[<span class="ruby-value">0</span><span class="ruby-operator">..</span><span class="ruby-identifier">zone</span>.<span class="ruby-identifier">index</span>(<span class="ruby-value str">'/'</span>) <span class="ruby-operator">-</span> <span class="ruby-value">1</span>] -81: <span class="ruby-identifier">res</span> = (<span class="ruby-identifier">newZone</span> <span class="ruby-operator">!=</span> <span class="ruby-identifier">zone</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">newZone</span> <span class="ruby-operator">!=</span> <span class="ruby-identifier">region</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">newZone</span> <span class="ruby-operator">!=</span> <span class="ruby-value str">'UTC'</span>) -82: <span class="ruby-comment cmt"># Restore TZ if it was set earlier.</span> -83: <span class="ruby-constant">ENV</span>[<span class="ruby-value str">'TZ'</span>] = <span class="ruby-identifier">tz</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">tz</span> -84: <span class="ruby-identifier">res</span> -85: <span class="ruby-keyword kw">end</span></pre> + <span class="ruby-comment cmt"># File lib/TjTime.rb, line 168</span> +168: <span class="ruby-keyword kw">def</span> <span class="ruby-constant">TjTime</span>.<span class="ruby-identifier">checkTimeZone</span>(<span class="ruby-identifier">zone</span>) +169: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">true</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">zone</span> <span class="ruby-operator">==</span> <span class="ruby-value str">'UTC'</span> +170: +171: <span class="ruby-comment cmt"># Valid time zones must be of the form 'Region/City'</span> +172: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">false</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">zone</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-value str">'/'</span>) +173: +174: <span class="ruby-comment cmt"># Save curent value of TZ</span> +175: <span class="ruby-identifier">tz</span> = <span class="ruby-constant">ENV</span>[<span class="ruby-value str">'TZ'</span>] +176: <span class="ruby-constant">ENV</span>[<span class="ruby-value str">'TZ'</span>] = <span class="ruby-identifier">zone</span> +177: <span class="ruby-identifier">newZone</span> = <span class="ruby-constant">Time</span>.<span class="ruby-identifier">new</span>.<span class="ruby-identifier">zone</span> +178: <span class="ruby-comment cmt"># If the time zone is valid, the OS can convert a zone like</span> +179: <span class="ruby-comment cmt"># 'America/Denver' into 'MST'. Unknown time zones are either not</span> +180: <span class="ruby-comment cmt"># converted or cause a fallback to UTC.</span> +181: <span class="ruby-comment cmt"># Since glibc 2.10 Time.new.zone only return the region for illegal</span> +182: <span class="ruby-comment cmt"># zones instead of the full zone string like it does on earlier</span> +183: <span class="ruby-comment cmt"># versions.</span> +184: <span class="ruby-identifier">region</span> = <span class="ruby-identifier">zone</span>[<span class="ruby-value">0</span><span class="ruby-operator">..</span><span class="ruby-identifier">zone</span>.<span class="ruby-identifier">index</span>(<span class="ruby-value str">'/'</span>) <span class="ruby-operator">-</span> <span class="ruby-value">1</span>] +185: <span class="ruby-identifier">res</span> = (<span class="ruby-identifier">newZone</span> <span class="ruby-operator">!=</span> <span class="ruby-identifier">zone</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">newZone</span> <span class="ruby-operator">!=</span> <span class="ruby-identifier">region</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">newZone</span> <span class="ruby-operator">!=</span> <span class="ruby-value str">'UTC'</span>) +186: <span class="ruby-comment cmt"># Restore TZ if it was set earlier.</span> +187: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">tz</span> +188: <span class="ruby-constant">ENV</span>[<span class="ruby-value str">'TZ'</span>] = <span class="ruby-identifier">tz</span> +189: <span class="ruby-keyword kw">else</span> +190: <span class="ruby-constant">ENV</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-value str">'TZ'</span>) +191: <span class="ruby-keyword kw">end</span> +192: <span class="ruby-identifier">res</span> +193: <span class="ruby-keyword kw">end</span></pre> </div> </div> @@ -773,14 +789,14 @@ <div class="method-source-code" id="gm-source"> <pre> - <span class="ruby-comment cmt"># File lib/TjTime.rb, line 53</span> -53: <span class="ruby-keyword kw">def</span> <span class="ruby-constant">TjTime</span>.<span class="ruby-identifier">gm</span>(*<span class="ruby-identifier">args</span>) -54: <span class="ruby-constant">TjTime</span>.<span class="ruby-identifier">new</span>(<span class="ruby-constant">Time</span>.<span class="ruby-identifier">gm</span>(*<span class="ruby-identifier">args</span>)) -55: <span class="ruby-keyword kw">end</span></pre> + <span class="ruby-comment cmt"># File lib/TjTime.rb, line 52</span> +52: <span class="ruby-keyword kw">def</span> <span class="ruby-constant">TjTime</span>.<span class="ruby-identifier">gm</span>(*<span class="ruby-identifier">args</span>) +53: <span class="ruby-constant">TjTime</span>.<span class="ruby-identifier">new</span>(<span class="ruby-constant">Time</span>.<span class="ruby-identifier">gm</span>(*<span class="ruby-identifier">args</span>)) +54: <span class="ruby-keyword kw">end</span></pre> </div> </div> @@ -810,14 +826,14 @@ <div class="method-source-code" id="local-source"> <pre> - <span class="ruby-comment cmt"># File lib/TjTime.rb, line 59</span> -59: <span class="ruby-keyword kw">def</span> <span class="ruby-constant">TjTime</span>.<span class="ruby-identifier">local</span>(*<span class="ruby-identifier">args</span>) -60: <span class="ruby-constant">TjTime</span>.<span class="ruby-identifier">new</span>(<span class="ruby-constant">Time</span>.<span class="ruby-identifier">local</span>(*<span class="ruby-identifier">args</span>).<span class="ruby-identifier">gmtime</span>) -61: <span class="ruby-keyword kw">end</span></pre> + <span class="ruby-comment cmt"># File lib/TjTime.rb, line 58</span> +58: <span class="ruby-keyword kw">def</span> <span class="ruby-constant">TjTime</span>.<span class="ruby-identifier">local</span>(*<span class="ruby-identifier">args</span>) +59: <span class="ruby-constant">TjTime</span>.<span class="ruby-identifier">new</span>(<span class="ruby-constant">Time</span>.<span class="ruby-identifier">local</span>(*<span class="ruby-identifier">args</span>).<span class="ruby-identifier">gmtime</span>) +60: <span class="ruby-keyword kw">end</span></pre> </div> </div> @@ -855,16 +871,15 @@ <span class="ruby-comment cmt"># File lib/TjTime.rb, line 35</span> 35: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">t</span>) 36: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">t</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Time</span>) 37: <span class="ruby-ivar">@time</span> = <span class="ruby-identifier">t</span> 38: <span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">t</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">String</span>) -39: <span class="ruby-identifier">d</span> = <span class="ruby-constant">DateTime</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-identifier">t</span>) -40: <span class="ruby-ivar">@time</span> = <span class="ruby-constant">Time</span>.<span class="ruby-identifier">mktime</span>(<span class="ruby-identifier">d</span>.<span class="ruby-identifier">year</span>, <span class="ruby-identifier">d</span>.<span class="ruby-identifier">mon</span>, <span class="ruby-identifier">d</span>.<span class="ruby-identifier">day</span>, <span class="ruby-identifier">d</span>.<span class="ruby-identifier">hour</span>, <span class="ruby-identifier">d</span>.<span class="ruby-identifier">min</span>, <span class="ruby-identifier">d</span>.<span class="ruby-identifier">sec</span>) -41: <span class="ruby-keyword kw">else</span> -42: <span class="ruby-ivar">@time</span> = <span class="ruby-constant">Time</span>.<span class="ruby-identifier">at</span>(<span class="ruby-identifier">t</span>) -43: <span class="ruby-keyword kw">end</span> -44: <span class="ruby-keyword kw">end</span></pre> +39: <span class="ruby-ivar">@time</span> = <span class="ruby-constant">TjTime</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-identifier">t</span>).<span class="ruby-identifier">time</span> +40: <span class="ruby-keyword kw">else</span> +41: <span class="ruby-ivar">@time</span> = <span class="ruby-constant">Time</span>.<span class="ruby-identifier">at</span>(<span class="ruby-identifier">t</span>) +42: <span class="ruby-keyword kw">end</span> +43: <span class="ruby-keyword kw">end</span></pre> </div> </div> @@ -893,24 +908,159 @@ <div class="method-source-code" id="now-source"> <pre> - <span class="ruby-comment cmt"># File lib/TjTime.rb, line 47</span> -47: <span class="ruby-keyword kw">def</span> <span class="ruby-constant">TjTime</span>.<span class="ruby-identifier">now</span> -48: <span class="ruby-constant">TjTime</span>.<span class="ruby-identifier">new</span>(<span class="ruby-constant">Time</span>.<span class="ruby-identifier">now</span>.<span class="ruby-identifier">gmtime</span>) -49: <span class="ruby-keyword kw">end</span></pre> + <span class="ruby-comment cmt"># File lib/TjTime.rb, line 46</span> +46: <span class="ruby-keyword kw">def</span> <span class="ruby-constant">TjTime</span>.<span class="ruby-identifier">now</span> +47: <span class="ruby-constant">TjTime</span>.<span class="ruby-identifier">new</span>(<span class="ruby-constant">Time</span>.<span class="ruby-identifier">now</span>.<span class="ruby-identifier">gmtime</span>) +48: <span class="ruby-keyword kw">end</span></pre> </div> </div> </div> + <div id="parse-method" class="method-detail "> + <a name="method-c-parse"></a> + + <div class="method-heading"> + + <span class="method-name">parse</span><span + class="method-args">(t)</span> + <span class="method-click-advice">click to toggle source</span> + + </div> + + <div class="method-description"> + + + + + + <div class="method-source-code" + id="parse-source"> +<pre> + <span class="ruby-comment cmt"># File lib/TjTime.rb, line 62</span> + 62: <span class="ruby-keyword kw">def</span> <span class="ruby-constant">TjTime</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-identifier">t</span>) + 63: <span class="ruby-identifier">year</span>, <span class="ruby-identifier">month</span>, <span class="ruby-identifier">day</span>, <span class="ruby-identifier">time</span>, <span class="ruby-identifier">zone</span> = <span class="ruby-identifier">t</span>.<span class="ruby-identifier">split</span>(<span class="ruby-value str">'-'</span>, <span class="ruby-value">5</span>) + 64: + 65: <span class="ruby-comment cmt"># Check the year</span> + 66: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">year</span> + 67: <span class="ruby-identifier">year</span> = <span class="ruby-identifier">year</span>.<span class="ruby-identifier">to_i</span> + 68: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">year</span> <span class="ruby-operator">&lt;</span> <span class="ruby-value">1970</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">year</span> <span class="ruby-operator">&gt;</span> <span class="ruby-value">2035</span> + 69: <span class="ruby-identifier">raise</span> <span class="ruby-constant">TjException</span>.<span class="ruby-identifier">new</span>, <span class="ruby-node">&quot;Year #{year} out of range (1970 - 2035)&quot;</span> + 70: <span class="ruby-keyword kw">end</span> + 71: <span class="ruby-keyword kw">else</span> + 72: <span class="ruby-identifier">raise</span> <span class="ruby-constant">TjException</span>.<span class="ruby-identifier">new</span>, <span class="ruby-value str">&quot;Year not specified&quot;</span> + 73: <span class="ruby-keyword kw">end</span> + 74: + 75: <span class="ruby-comment cmt"># Check the month</span> + 76: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">month</span> + 77: <span class="ruby-identifier">month</span> = <span class="ruby-identifier">month</span>.<span class="ruby-identifier">to_i</span> + 78: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">month</span> <span class="ruby-operator">&lt;</span> <span class="ruby-value">1</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">month</span> <span class="ruby-operator">&gt;</span> <span class="ruby-value">12</span> + 79: <span class="ruby-identifier">raise</span> <span class="ruby-constant">TjException</span>.<span class="ruby-identifier">new</span>, <span class="ruby-node">&quot;Month #{month} out of range (1 - 12)&quot;</span> + 80: <span class="ruby-keyword kw">end</span> + 81: <span class="ruby-keyword kw">else</span> + 82: <span class="ruby-identifier">raise</span> <span class="ruby-constant">TjException</span>.<span class="ruby-identifier">new</span>, <span class="ruby-value str">&quot;Month not specified&quot;</span> + 83: <span class="ruby-keyword kw">end</span> + 84: + 85: <span class="ruby-comment cmt"># Check the day</span> + 86: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">day</span> + 87: <span class="ruby-identifier">day</span> = <span class="ruby-identifier">day</span>.<span class="ruby-identifier">to_i</span> + 88: <span class="ruby-identifier">maxDay</span> = [ <span class="ruby-value">0</span>, <span class="ruby-value">31</span>, <span class="ruby-constant">Date</span>.<span class="ruby-identifier">gregorian_leap?</span>(<span class="ruby-identifier">year</span>) <span class="ruby-operator">?</span> <span class="ruby-value">29</span> <span class="ruby-operator">:</span> <span class="ruby-value">28</span>, <span class="ruby-value">31</span>, <span class="ruby-value">30</span>, <span class="ruby-value">31</span>, + 89: <span class="ruby-value">30</span>, <span class="ruby-value">31</span>, <span class="ruby-value">31</span>, <span class="ruby-value">30</span>, <span class="ruby-value">31</span>, <span class="ruby-value">30</span>, <span class="ruby-value">31</span> ] + 90: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">month</span> <span class="ruby-operator">&lt;</span> <span class="ruby-value">1</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">month</span> <span class="ruby-operator">&gt;</span> <span class="ruby-identifier">maxDay</span>[<span class="ruby-identifier">month</span>] + 91: <span class="ruby-identifier">raise</span> <span class="ruby-constant">TjException</span>.<span class="ruby-identifier">new</span>, <span class="ruby-node">&quot;Day #{day} out of range (1 - #{maxDay[month]})&quot;</span> + 92: <span class="ruby-keyword kw">end</span> + 93: <span class="ruby-keyword kw">else</span> + 94: <span class="ruby-identifier">raise</span> <span class="ruby-constant">TjException</span>.<span class="ruby-identifier">new</span>, <span class="ruby-value str">&quot;Day not specified&quot;</span> + 95: <span class="ruby-keyword kw">end</span> + 96: + 97: <span class="ruby-comment cmt"># The time is optional. Will be expanded to 00:00:00.</span> + 98: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">time</span> + 99: <span class="ruby-identifier">hour</span>, <span class="ruby-identifier">minute</span>, <span class="ruby-identifier">second</span> = <span class="ruby-identifier">time</span>.<span class="ruby-identifier">split</span>(<span class="ruby-value str">':'</span>) +100: +101: <span class="ruby-comment cmt"># Check hour</span> +102: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">hour</span> +103: <span class="ruby-identifier">hour</span> = <span class="ruby-identifier">hour</span>.<span class="ruby-identifier">to_i</span> +104: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">hour</span> <span class="ruby-operator">&lt;</span> <span class="ruby-value">0</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">hour</span> <span class="ruby-operator">&gt;</span> <span class="ruby-value">23</span> +105: <span class="ruby-identifier">raise</span> <span class="ruby-constant">TjException</span>.<span class="ruby-identifier">new</span>, <span class="ruby-node">&quot;Hour #{hour} out of range (0 - 23)&quot;</span> +106: <span class="ruby-keyword kw">end</span> +107: <span class="ruby-keyword kw">else</span> +108: <span class="ruby-identifier">raise</span> <span class="ruby-constant">TjException</span>.<span class="ruby-identifier">new</span>, <span class="ruby-value str">&quot;Hour not specified&quot;</span> +109: <span class="ruby-keyword kw">end</span> +110: +111: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">minute</span> +112: <span class="ruby-identifier">minute</span> = <span class="ruby-identifier">minute</span>.<span class="ruby-identifier">to_i</span> +113: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">minute</span> <span class="ruby-operator">&lt;</span> <span class="ruby-value">0</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">minute</span> <span class="ruby-operator">&gt;</span> <span class="ruby-value">59</span> +114: <span class="ruby-identifier">raise</span> <span class="ruby-constant">TjException</span>.<span class="ruby-identifier">new</span>, <span class="ruby-node">&quot;Minute #{minute} out of range (0 - 59)&quot;</span> +115: <span class="ruby-keyword kw">end</span> +116: <span class="ruby-keyword kw">else</span> +117: <span class="ruby-identifier">raise</span> <span class="ruby-constant">TjException</span>.<span class="ruby-identifier">new</span>, <span class="ruby-value str">&quot;Minute not specified&quot;</span> +118: <span class="ruby-keyword kw">end</span> +119: +120: <span class="ruby-comment cmt"># Check sencond. This value is optional and defaults to 0.</span> +121: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">second</span> +122: <span class="ruby-identifier">second</span> = <span class="ruby-identifier">second</span>.<span class="ruby-identifier">to_i</span> +123: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">second</span> <span class="ruby-operator">&lt;</span> <span class="ruby-value">0</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">second</span> <span class="ruby-operator">&gt;</span> <span class="ruby-value">59</span> +124: <span class="ruby-identifier">raise</span> <span class="ruby-constant">TjException</span>.<span class="ruby-identifier">new</span>, <span class="ruby-node">&quot;Second #{second} out of range (0 - 59)&quot;</span> +125: <span class="ruby-keyword kw">end</span> +126: <span class="ruby-keyword kw">else</span> +127: <span class="ruby-identifier">second</span> = <span class="ruby-value">0</span> +128: <span class="ruby-keyword kw">end</span> +129: <span class="ruby-keyword kw">else</span> +130: <span class="ruby-identifier">hour</span> = <span class="ruby-identifier">minute</span> = <span class="ruby-identifier">second</span> = <span class="ruby-value">0</span> +131: <span class="ruby-keyword kw">end</span> +132: +133: <span class="ruby-comment cmt"># The zone is optional and defaults to the current time zone.</span> +134: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">zone</span> +135: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">zone</span>[<span class="ruby-value">0</span>] <span class="ruby-operator">!=</span> <span class="ruby-value">--</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">zone</span>[<span class="ruby-value">0</span>] <span class="ruby-operator">!=</span> <span class="ruby-value">++</span> +136: <span class="ruby-identifier">raise</span> <span class="ruby-constant">TjException</span>.<span class="ruby-identifier">new</span>, <span class="ruby-value str">&quot;Time zone adjustment must be prefixed by &quot;</span> <span class="ruby-operator">+</span> +137: <span class="ruby-node">&quot;+ or -, not #{zone[0]}&quot;</span> +138: <span class="ruby-keyword kw">end</span> +139: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">zone</span>.<span class="ruby-identifier">length</span> <span class="ruby-operator">!=</span> <span class="ruby-value">5</span> +140: <span class="ruby-identifier">raise</span> <span class="ruby-constant">TjException</span>.<span class="ruby-identifier">new</span>, <span class="ruby-value str">&quot;Time zone adjustment must use (+/-)HHMM format&quot;</span> +141: <span class="ruby-keyword kw">end</span> +142: +143: <span class="ruby-identifier">date</span> = <span class="ruby-constant">Time</span>.<span class="ruby-identifier">utc</span>(<span class="ruby-identifier">year</span>, <span class="ruby-identifier">month</span>, <span class="ruby-identifier">day</span>, <span class="ruby-identifier">hour</span>, <span class="ruby-identifier">minute</span>, <span class="ruby-identifier">second</span>) +144: <span class="ruby-identifier">sign</span> = <span class="ruby-identifier">zone</span>[<span class="ruby-value">0</span>] <span class="ruby-operator">==</span> <span class="ruby-value">--</span> <span class="ruby-operator">?</span> <span class="ruby-value">1</span> <span class="ruby-operator">:</span> <span class="ruby-value">1</span> +145: <span class="ruby-identifier">tzHour</span> = <span class="ruby-identifier">zone</span>[<span class="ruby-value">1</span><span class="ruby-operator">..</span><span class="ruby-value">2</span>].<span class="ruby-identifier">to_i</span> +146: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">tzHour</span> <span class="ruby-operator">&lt;</span> <span class="ruby-value">0</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">tzHour</span> <span class="ruby-operator">&gt;</span> <span class="ruby-value">12</span> +147: <span class="ruby-identifier">raise</span> <span class="ruby-constant">TjException</span>.<span class="ruby-identifier">new</span>, <span class="ruby-value str">&quot;Time zone adjustment hour out of range &quot;</span> <span class="ruby-operator">+</span> +148: <span class="ruby-node">&quot;(0 - 12) but is #{tzHour}&quot;</span> +149: <span class="ruby-keyword kw">end</span> +150: <span class="ruby-identifier">tzMinute</span> = <span class="ruby-identifier">zone</span>[<span class="ruby-value">3</span><span class="ruby-operator">..</span><span class="ruby-value">4</span>].<span class="ruby-identifier">to_i</span> +151: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">tzMinute</span> <span class="ruby-operator">&lt;</span> <span class="ruby-value">0</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">tzMinute</span> <span class="ruby-operator">&gt;</span> <span class="ruby-value">59</span> +152: <span class="ruby-identifier">raise</span> <span class="ruby-constant">TjException</span>.<span class="ruby-identifier">new</span>, <span class="ruby-value str">&quot;Time zone adjustment minute out of range &quot;</span> <span class="ruby-operator">+</span> +153: <span class="ruby-node">&quot;(0 - 59) but is #{tzMinute}&quot;</span> +154: <span class="ruby-keyword kw">end</span> +155: <span class="ruby-identifier">date</span> <span class="ruby-operator">+=</span> <span class="ruby-identifier">sign</span> * (<span class="ruby-identifier">tzHour</span> * <span class="ruby-value">3600</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">tzMinute</span> * <span class="ruby-value">60</span>) +156: <span class="ruby-keyword kw">else</span> +157: <span class="ruby-identifier">date</span> = <span class="ruby-constant">Time</span>.<span class="ruby-identifier">mktime</span>(<span class="ruby-identifier">year</span>, <span class="ruby-identifier">month</span>, <span class="ruby-identifier">day</span>, <span class="ruby-identifier">hour</span>, <span class="ruby-identifier">minute</span>, <span class="ruby-identifier">second</span>) +158: <span class="ruby-keyword kw">end</span> +159: +160: <span class="ruby-comment cmt">#puts &quot;--&gt; #{t}&quot;</span> +161: <span class="ruby-comment cmt">#puts(&quot;&gt;&gt;&gt; #{year}-#{month}-#{day}-#{hour}:#{minute}:#{second}&quot; +</span> +162: <span class="ruby-comment cmt"># &quot;#{zone ? &quot;-#{tzHour}:#{tzMinute}&quot; : &quot;&quot;}&quot;)</span> +163: <span class="ruby-comment cmt">#puts &quot;=== #{date}&quot;</span> +164: <span class="ruby-constant">TjTime</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">date</span>) +165: <span class="ruby-keyword kw">end</span></pre> + </div> + + </div> + + + + + </div> + + </div> <div id="public-instance-method-details" class="method-section section"> <h3 class="section-header">Public Instance Methods</h3> @@ -936,14 +1086,14 @@ <div class="method-source-code" id="--source"> <pre> - <span class="ruby-comment cmt"># File lib/TjTime.rb, line 115</span> -115: <span class="ruby-keyword kw">def</span> <span class="ruby-operator">%</span>(<span class="ruby-identifier">val</span>) -116: <span class="ruby-ivar">@time</span>.<span class="ruby-identifier">to_i</span> <span class="ruby-operator">%</span> <span class="ruby-identifier">val</span> -117: <span class="ruby-keyword kw">end</span></pre> + <span class="ruby-comment cmt"># File lib/TjTime.rb, line 223</span> +223: <span class="ruby-keyword kw">def</span> <span class="ruby-operator">%</span>(<span class="ruby-identifier">val</span>) +224: <span class="ruby-ivar">@time</span>.<span class="ruby-identifier">to_i</span> <span class="ruby-operator">%</span> <span class="ruby-identifier">val</span> +225: <span class="ruby-keyword kw">end</span></pre> </div> </div> @@ -972,14 +1122,14 @@ <div class="method-source-code" id="--source"> <pre> - <span class="ruby-comment cmt"># File lib/TjTime.rb, line 100</span> -100: <span class="ruby-keyword kw">def</span> <span class="ruby-operator">+</span>(<span class="ruby-identifier">secs</span>) -101: <span class="ruby-constant">TjTime</span>.<span class="ruby-identifier">new</span>(<span class="ruby-ivar">@time</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">secs</span>) -102: <span class="ruby-keyword kw">end</span></pre> + <span class="ruby-comment cmt"># File lib/TjTime.rb, line 208</span> +208: <span class="ruby-keyword kw">def</span> <span class="ruby-operator">+</span>(<span class="ruby-identifier">secs</span>) +209: <span class="ruby-constant">TjTime</span>.<span class="ruby-identifier">new</span>(<span class="ruby-ivar">@time</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">secs</span>) +210: <span class="ruby-keyword kw">end</span></pre> </div> </div> @@ -1009,18 +1159,18 @@ <div class="method-source-code" id="--source"> <pre> - <span class="ruby-comment cmt"># File lib/TjTime.rb, line 106</span> -106: <span class="ruby-keyword kw">def</span> <span class="ruby-operator">-</span>(<span class="ruby-identifier">arg</span>) -107: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">arg</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">TjTime</span>) -108: <span class="ruby-ivar">@time</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">arg</span>.<span class="ruby-identifier">time</span> -109: <span class="ruby-keyword kw">else</span> -110: <span class="ruby-constant">TjTime</span>.<span class="ruby-identifier">new</span>(<span class="ruby-ivar">@time</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">arg</span>) -111: <span class="ruby-keyword kw">end</span> -112: <span class="ruby-keyword kw">end</span></pre> + <span class="ruby-comment cmt"># File lib/TjTime.rb, line 214</span> +214: <span class="ruby-keyword kw">def</span> <span class="ruby-operator">-</span>(<span class="ruby-identifier">arg</span>) +215: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">arg</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">TjTime</span>) +216: <span class="ruby-ivar">@time</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">arg</span>.<span class="ruby-identifier">time</span> +217: <span class="ruby-keyword kw">else</span> +218: <span class="ruby-constant">TjTime</span>.<span class="ruby-identifier">new</span>(<span class="ruby-ivar">@time</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">arg</span>) +219: <span class="ruby-keyword kw">end</span> +220: <span class="ruby-keyword kw">end</span></pre> </div> </div> @@ -1049,14 +1199,14 @@ <div class="method-source-code" id="--source"> <pre> - <span class="ruby-comment cmt"># File lib/TjTime.rb, line 120</span> -120: <span class="ruby-keyword kw">def</span> <span class="ruby-operator">&lt;</span>(<span class="ruby-identifier">t</span>) -121: <span class="ruby-ivar">@time</span> <span class="ruby-operator">&lt;</span> <span class="ruby-identifier">t</span>.<span class="ruby-identifier">time</span> -122: <span class="ruby-keyword kw">end</span></pre> + <span class="ruby-comment cmt"># File lib/TjTime.rb, line 228</span> +228: <span class="ruby-keyword kw">def</span> <span class="ruby-operator">&lt;</span>(<span class="ruby-identifier">t</span>) +229: <span class="ruby-ivar">@time</span> <span class="ruby-operator">&lt;</span> <span class="ruby-identifier">t</span>.<span class="ruby-identifier">time</span> +230: <span class="ruby-keyword kw">end</span></pre> </div> </div> @@ -1085,14 +1235,14 @@ <div class="method-source-code" id="--source"> <pre> - <span class="ruby-comment cmt"># File lib/TjTime.rb, line 125</span> -125: <span class="ruby-keyword kw">def</span> <span class="ruby-operator">&lt;=</span>(<span class="ruby-identifier">t</span>) -126: <span class="ruby-ivar">@time</span> <span class="ruby-operator">&lt;=</span> <span class="ruby-identifier">t</span>.<span class="ruby-identifier">time</span> -127: <span class="ruby-keyword kw">end</span></pre> + <span class="ruby-comment cmt"># File lib/TjTime.rb, line 233</span> +233: <span class="ruby-keyword kw">def</span> <span class="ruby-operator">&lt;=</span>(<span class="ruby-identifier">t</span>) +234: <span class="ruby-ivar">@time</span> <span class="ruby-operator">&lt;=</span> <span class="ruby-identifier">t</span>.<span class="ruby-identifier">time</span> +235: <span class="ruby-keyword kw">end</span></pre> </div> </div> @@ -1121,14 +1271,14 @@ <div class="method-source-code" id="--source"> <pre> - <span class="ruby-comment cmt"># File lib/TjTime.rb, line 146</span> -146: <span class="ruby-keyword kw">def</span> <span class="ruby-operator">&lt;=&gt;</span>(<span class="ruby-identifier">t</span>) -147: <span class="ruby-ivar">@time</span> <span class="ruby-operator">&lt;=&gt;</span> <span class="ruby-identifier">t</span>.<span class="ruby-identifier">time</span> -148: <span class="ruby-keyword kw">end</span></pre> + <span class="ruby-comment cmt"># File lib/TjTime.rb, line 254</span> +254: <span class="ruby-keyword kw">def</span> <span class="ruby-operator">&lt;=&gt;</span>(<span class="ruby-identifier">t</span>) +255: <span class="ruby-ivar">@time</span> <span class="ruby-operator">&lt;=&gt;</span> <span class="ruby-identifier">t</span>.<span class="ruby-identifier">time</span> +256: <span class="ruby-keyword kw">end</span></pre> </div> </div> @@ -1157,15 +1307,15 @@ <div class="method-source-code" id="--source"> <pre> - <span class="ruby-comment cmt"># File lib/TjTime.rb, line 140</span> -140: <span class="ruby-keyword kw">def</span> <span class="ruby-operator">==</span>(<span class="ruby-identifier">t</span>) -141: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">false</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">t</span>.<span class="ruby-identifier">nil?</span> -142: <span class="ruby-ivar">@time</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">t</span>.<span class="ruby-identifier">time</span> -143: <span class="ruby-keyword kw">end</span></pre> + <span class="ruby-comment cmt"># File lib/TjTime.rb, line 248</span> +248: <span class="ruby-keyword kw">def</span> <span class="ruby-operator">==</span>(<span class="ruby-identifier">t</span>) +249: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">false</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">t</span>.<span class="ruby-identifier">nil?</span> +250: <span class="ruby-ivar">@time</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">t</span>.<span class="ruby-identifier">time</span> +251: <span class="ruby-keyword kw">end</span></pre> </div> </div> @@ -1194,14 +1344,14 @@ <div class="method-source-code" id="--source"> <pre> - <span class="ruby-comment cmt"># File lib/TjTime.rb, line 130</span> -130: <span class="ruby-keyword kw">def</span> <span class="ruby-operator">&gt;</span>(<span class="ruby-identifier">t</span>) -131: <span class="ruby-ivar">@time</span> <span class="ruby-operator">&gt;</span> <span class="ruby-identifier">t</span>.<span class="ruby-identifier">time</span> -132: <span class="ruby-keyword kw">end</span></pre> + <span class="ruby-comment cmt"># File lib/TjTime.rb, line 238</span> +238: <span class="ruby-keyword kw">def</span> <span class="ruby-operator">&gt;</span>(<span class="ruby-identifier">t</span>) +239: <span class="ruby-ivar">@time</span> <span class="ruby-operator">&gt;</span> <span class="ruby-identifier">t</span>.<span class="ruby-identifier">time</span> +240: <span class="ruby-keyword kw">end</span></pre> </div> </div> @@ -1230,14 +1380,14 @@ <div class="method-source-code" id="--source"> <pre> - <span class="ruby-comment cmt"># File lib/TjTime.rb, line 135</span> -135: <span class="ruby-keyword kw">def</span> <span class="ruby-operator">&gt;=</span>(<span class="ruby-identifier">t</span>) -136: <span class="ruby-ivar">@time</span> <span class="ruby-operator">&gt;=</span> <span class="ruby-identifier">t</span>.<span class="ruby-identifier">time</span> -137: <span class="ruby-keyword kw">end</span></pre> + <span class="ruby-comment cmt"># File lib/TjTime.rb, line 243</span> +243: <span class="ruby-keyword kw">def</span> <span class="ruby-operator">&gt;=</span>(<span class="ruby-identifier">t</span>) +244: <span class="ruby-ivar">@time</span> <span class="ruby-operator">&gt;=</span> <span class="ruby-identifier">t</span>.<span class="ruby-identifier">time</span> +245: <span class="ruby-keyword kw">end</span></pre> </div> </div> @@ -1267,14 +1417,14 @@ <div class="method-source-code" id="align-source"> <pre> - <span class="ruby-comment cmt"># File lib/TjTime.rb, line 88</span> -88: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">align</span>(<span class="ruby-identifier">clock</span>) -89: <span class="ruby-constant">TjTime</span>.<span class="ruby-identifier">new</span>((<span class="ruby-ivar">@time</span>.<span class="ruby-identifier">to_i</span> <span class="ruby-operator">/</span> <span class="ruby-identifier">clock</span>) * <span class="ruby-identifier">clock</span>) -90: <span class="ruby-keyword kw">end</span></pre> + <span class="ruby-comment cmt"># File lib/TjTime.rb, line 196</span> +196: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">align</span>(<span class="ruby-identifier">clock</span>) +197: <span class="ruby-constant">TjTime</span>.<span class="ruby-identifier">new</span>((<span class="ruby-ivar">@time</span>.<span class="ruby-identifier">to_i</span> <span class="ruby-operator">/</span> <span class="ruby-identifier">clock</span>) * <span class="ruby-identifier">clock</span>) +198: <span class="ruby-keyword kw">end</span></pre> </div> </div> @@ -1303,18 +1453,18 @@ <div class="method-source-code" id="begin-f-our-source"> <pre> - <span class="ruby-comment cmt"># File lib/TjTime.rb, line 161</span> -161: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">beginOfHour</span> -162: <span class="ruby-identifier">t</span> = <span class="ruby-ivar">@time</span>.<span class="ruby-identifier">localtime</span>.<span class="ruby-identifier">to_a</span> -163: <span class="ruby-identifier">t</span>[<span class="ruby-value">0</span>, <span class="ruby-value">2</span>] = <span class="ruby-constant">Array</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">2</span>, <span class="ruby-value">0</span>) -164: <span class="ruby-identifier">t</span>.<span class="ruby-identifier">slice!</span>(<span class="ruby-value">6</span>, <span class="ruby-value">4</span>) -165: <span class="ruby-identifier">t</span>.<span class="ruby-identifier">reverse!</span> -166: <span class="ruby-constant">TjTime</span>.<span class="ruby-identifier">new</span>(<span class="ruby-constant">Time</span>.<span class="ruby-identifier">local</span>(*<span class="ruby-identifier">t</span>)) -167: <span class="ruby-keyword kw">end</span></pre> + <span class="ruby-comment cmt"># File lib/TjTime.rb, line 269</span> +269: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">beginOfHour</span> +270: <span class="ruby-identifier">t</span> = <span class="ruby-ivar">@time</span>.<span class="ruby-identifier">localtime</span>.<span class="ruby-identifier">to_a</span> +271: <span class="ruby-identifier">t</span>[<span class="ruby-value">0</span>, <span class="ruby-value">2</span>] = <span class="ruby-constant">Array</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">2</span>, <span class="ruby-value">0</span>) +272: <span class="ruby-identifier">t</span>.<span class="ruby-identifier">slice!</span>(<span class="ruby-value">6</span>, <span class="ruby-value">4</span>) +273: <span class="ruby-identifier">t</span>.<span class="ruby-identifier">reverse!</span> +274: <span class="ruby-constant">TjTime</span>.<span class="ruby-identifier">new</span>(<span class="ruby-constant">Time</span>.<span class="ruby-identifier">local</span>(*<span class="ruby-identifier">t</span>)) +275: <span class="ruby-keyword kw">end</span></pre> </div> </div> @@ -1343,19 +1493,19 @@ <div class="method-source-code" id="begin-f-onth-source"> <pre> - <span class="ruby-comment cmt"># File lib/TjTime.rb, line 194</span> -194: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">beginOfMonth</span> -195: <span class="ruby-identifier">t</span> = <span class="ruby-ivar">@time</span>.<span class="ruby-identifier">localtime</span>.<span class="ruby-identifier">to_a</span> -196: <span class="ruby-identifier">t</span>[<span class="ruby-value">0</span>, <span class="ruby-value">3</span>] = <span class="ruby-constant">Array</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">3</span>, <span class="ruby-value">0</span>) -197: <span class="ruby-identifier">t</span>[<span class="ruby-value">3</span>] = <span class="ruby-value">1</span> -198: <span class="ruby-identifier">t</span>.<span class="ruby-identifier">slice!</span>(<span class="ruby-value">6</span>, <span class="ruby-value">4</span>) -199: <span class="ruby-identifier">t</span>.<span class="ruby-identifier">reverse!</span> -200: <span class="ruby-constant">TjTime</span>.<span class="ruby-identifier">new</span>(<span class="ruby-constant">Time</span>.<span class="ruby-identifier">local</span>(*<span class="ruby-identifier">t</span>)) -201: <span class="ruby-keyword kw">end</span></pre> + <span class="ruby-comment cmt"># File lib/TjTime.rb, line 302</span> +302: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">beginOfMonth</span> +303: <span class="ruby-identifier">t</span> = <span class="ruby-ivar">@time</span>.<span class="ruby-identifier">localtime</span>.<span class="ruby-identifier">to_a</span> +304: <span class="ruby-identifier">t</span>[<span class="ruby-value">0</span>, <span class="ruby-value">3</span>] = <span class="ruby-constant">Array</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">3</span>, <span class="ruby-value">0</span>) +305: <span class="ruby-identifier">t</span>[<span class="ruby-value">3</span>] = <span class="ruby-value">1</span> +306: <span class="ruby-identifier">t</span>.<span class="ruby-identifier">slice!</span>(<span class="ruby-value">6</span>, <span class="ruby-value">4</span>) +307: <span class="ruby-identifier">t</span>.<span class="ruby-identifier">reverse!</span> +308: <span class="ruby-constant">TjTime</span>.<span class="ruby-identifier">new</span>(<span class="ruby-constant">Time</span>.<span class="ruby-identifier">local</span>(*<span class="ruby-identifier">t</span>)) +309: <span class="ruby-keyword kw">end</span></pre> </div> </div> @@ -1384,20 +1534,20 @@ <div class="method-source-code" id="begin-f-uarter-source"> <pre> - <span class="ruby-comment cmt"># File lib/TjTime.rb, line 204</span> -204: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">beginOfQuarter</span> -205: <span class="ruby-identifier">t</span> = <span class="ruby-ivar">@time</span>.<span class="ruby-identifier">localtime</span>.<span class="ruby-identifier">to_a</span> -206: <span class="ruby-identifier">t</span>[<span class="ruby-value">0</span>, <span class="ruby-value">3</span>] = <span class="ruby-constant">Array</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">3</span>, <span class="ruby-value">0</span>) -207: <span class="ruby-identifier">t</span>[<span class="ruby-value">3</span>] = <span class="ruby-value">1</span> -208: <span class="ruby-identifier">t</span>[<span class="ruby-value">4</span>] = ((<span class="ruby-identifier">t</span>[<span class="ruby-value">4</span>] <span class="ruby-operator">-</span> <span class="ruby-value">1</span>) <span class="ruby-operator">%</span> <span class="ruby-value">3</span>) <span class="ruby-operator">+</span> <span class="ruby-value">1</span> -209: <span class="ruby-identifier">t</span>.<span class="ruby-identifier">slice!</span>(<span class="ruby-value">6</span>, <span class="ruby-value">4</span>) -210: <span class="ruby-identifier">t</span>.<span class="ruby-identifier">reverse!</span> -211: <span class="ruby-constant">TjTime</span>.<span class="ruby-identifier">new</span>(<span class="ruby-constant">Time</span>.<span class="ruby-identifier">local</span>(*<span class="ruby-identifier">t</span>)) -212: <span class="ruby-keyword kw">end</span></pre> + <span class="ruby-comment cmt"># File lib/TjTime.rb, line 312</span> +312: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">beginOfQuarter</span> +313: <span class="ruby-identifier">t</span> = <span class="ruby-ivar">@time</span>.<span class="ruby-identifier">localtime</span>.<span class="ruby-identifier">to_a</span> +314: <span class="ruby-identifier">t</span>[<span class="ruby-value">0</span>, <span class="ruby-value">3</span>] = <span class="ruby-constant">Array</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">3</span>, <span class="ruby-value">0</span>) +315: <span class="ruby-identifier">t</span>[<span class="ruby-value">3</span>] = <span class="ruby-value">1</span> +316: <span class="ruby-identifier">t</span>[<span class="ruby-value">4</span>] = ((<span class="ruby-identifier">t</span>[<span class="ruby-value">4</span>] <span class="ruby-operator">-</span> <span class="ruby-value">1</span>) <span class="ruby-operator">%</span> <span class="ruby-value">3</span>) <span class="ruby-operator">+</span> <span class="ruby-value">1</span> +317: <span class="ruby-identifier">t</span>.<span class="ruby-identifier">slice!</span>(<span class="ruby-value">6</span>, <span class="ruby-value">4</span>) +318: <span class="ruby-identifier">t</span>.<span class="ruby-identifier">reverse!</span> +319: <span class="ruby-constant">TjTime</span>.<span class="ruby-identifier">new</span>(<span class="ruby-constant">Time</span>.<span class="ruby-identifier">local</span>(*<span class="ruby-identifier">t</span>)) +320: <span class="ruby-keyword kw">end</span></pre> </div> </div> @@ -1427,23 +1577,23 @@ <div class="method-source-code" id="begin-f-eek-source"> <pre> - <span class="ruby-comment cmt"># File lib/TjTime.rb, line 180</span> -180: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">beginOfWeek</span>(<span class="ruby-identifier">startMonday</span>) -181: <span class="ruby-identifier">t</span> = <span class="ruby-ivar">@time</span>.<span class="ruby-identifier">to_a</span> -182: <span class="ruby-comment cmt"># Set time to noon, 12:00:00</span> -183: <span class="ruby-identifier">t</span>[<span class="ruby-value">0</span>, <span class="ruby-value">3</span>] = [ <span class="ruby-value">0</span>, <span class="ruby-value">0</span>, <span class="ruby-value">12</span> ] -184: <span class="ruby-identifier">weekday</span> = <span class="ruby-identifier">t</span>[<span class="ruby-value">6</span>] -185: <span class="ruby-identifier">t</span>.<span class="ruby-identifier">slice!</span>(<span class="ruby-value">6</span>, <span class="ruby-value">4</span>) -186: <span class="ruby-identifier">t</span>.<span class="ruby-identifier">reverse!</span> -187: <span class="ruby-comment cmt"># Substract the number of days determined by the weekday t[6] and set time</span> -188: <span class="ruby-comment cmt"># to midnight of that day.</span> -189: (<span class="ruby-constant">TjTime</span>.<span class="ruby-identifier">new</span>(<span class="ruby-constant">Time</span>.<span class="ruby-identifier">local</span>(*<span class="ruby-identifier">t</span>)) <span class="ruby-operator">-</span> -190: (<span class="ruby-identifier">weekday</span> <span class="ruby-operator">-</span> (<span class="ruby-identifier">startMonday</span> <span class="ruby-operator">?</span> <span class="ruby-value">1</span> <span class="ruby-operator">:</span> <span class="ruby-value">0</span>)) * <span class="ruby-value">60</span> * <span class="ruby-value">60</span> * <span class="ruby-value">24</span>).<span class="ruby-identifier">midnight</span> -191: <span class="ruby-keyword kw">end</span></pre> + <span class="ruby-comment cmt"># File lib/TjTime.rb, line 288</span> +288: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">beginOfWeek</span>(<span class="ruby-identifier">startMonday</span>) +289: <span class="ruby-identifier">t</span> = <span class="ruby-ivar">@time</span>.<span class="ruby-identifier">to_a</span> +290: <span class="ruby-comment cmt"># Set time to noon, 12:00:00</span> +291: <span class="ruby-identifier">t</span>[<span class="ruby-value">0</span>, <span class="ruby-value">3</span>] = [ <span class="ruby-value">0</span>, <span class="ruby-value">0</span>, <span class="ruby-value">12</span> ] +292: <span class="ruby-identifier">weekday</span> = <span class="ruby-identifier">t</span>[<span class="ruby-value">6</span>] +293: <span class="ruby-identifier">t</span>.<span class="ruby-identifier">slice!</span>(<span class="ruby-value">6</span>, <span class="ruby-value">4</span>) +294: <span class="ruby-identifier">t</span>.<span class="ruby-identifier">reverse!</span> +295: <span class="ruby-comment cmt"># Substract the number of days determined by the weekday t[6] and set time</span> +296: <span class="ruby-comment cmt"># to midnight of that day.</span> +297: (<span class="ruby-constant">TjTime</span>.<span class="ruby-identifier">new</span>(<span class="ruby-constant">Time</span>.<span class="ruby-identifier">local</span>(*<span class="ruby-identifier">t</span>)) <span class="ruby-operator">-</span> +298: (<span class="ruby-identifier">weekday</span> <span class="ruby-operator">-</span> (<span class="ruby-identifier">startMonday</span> <span class="ruby-operator">?</span> <span class="ruby-value">1</span> <span class="ruby-operator">:</span> <span class="ruby-value">0</span>)) * <span class="ruby-value">60</span> * <span class="ruby-value">60</span> * <span class="ruby-value">24</span>).<span class="ruby-identifier">midnight</span> +299: <span class="ruby-keyword kw">end</span></pre> </div> </div> @@ -1472,19 +1622,19 @@ <div class="method-source-code" id="begin-f-ear-source"> <pre> - <span class="ruby-comment cmt"># File lib/TjTime.rb, line 215</span> -215: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">beginOfYear</span> -216: <span class="ruby-identifier">t</span> = <span class="ruby-ivar">@time</span>.<span class="ruby-identifier">localtime</span>.<span class="ruby-identifier">to_a</span> -217: <span class="ruby-identifier">t</span>[<span class="ruby-value">0</span>, <span class="ruby-value">3</span>] = <span class="ruby-constant">Array</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">3</span>, <span class="ruby-value">0</span>) -218: <span class="ruby-identifier">t</span>[<span class="ruby-value">3</span>, <span class="ruby-value">2</span>] = <span class="ruby-constant">Array</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">2</span>, <span class="ruby-value">1</span>) -219: <span class="ruby-identifier">t</span>.<span class="ruby-identifier">slice!</span>(<span class="ruby-value">6</span>, <span class="ruby-value">4</span>) -220: <span class="ruby-identifier">t</span>.<span class="ruby-identifier">reverse!</span> -221: <span class="ruby-constant">TjTime</span>.<span class="ruby-identifier">new</span>(<span class="ruby-constant">Time</span>.<span class="ruby-identifier">local</span>(*<span class="ruby-identifier">t</span>)) -222: <span class="ruby-keyword kw">end</span></pre> + <span class="ruby-comment cmt"># File lib/TjTime.rb, line 323</span> +323: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">beginOfYear</span> +324: <span class="ruby-identifier">t</span> = <span class="ruby-ivar">@time</span>.<span class="ruby-identifier">localtime</span>.<span class="ruby-identifier">to_a</span> +325: <span class="ruby-identifier">t</span>[<span class="ruby-value">0</span>, <span class="ruby-value">3</span>] = <span class="ruby-constant">Array</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">3</span>, <span class="ruby-value">0</span>) +326: <span class="ruby-identifier">t</span>[<span class="ruby-value">3</span>, <span class="ruby-value">2</span>] = <span class="ruby-constant">Array</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">2</span>, <span class="ruby-value">1</span>) +327: <span class="ruby-identifier">t</span>.<span class="ruby-identifier">slice!</span>(<span class="ruby-value">6</span>, <span class="ruby-value">4</span>) +328: <span class="ruby-identifier">t</span>.<span class="ruby-identifier">reverse!</span> +329: <span class="ruby-constant">TjTime</span>.<span class="ruby-identifier">new</span>(<span class="ruby-constant">Time</span>.<span class="ruby-identifier">local</span>(*<span class="ruby-identifier">t</span>)) +330: <span class="ruby-keyword kw">end</span></pre> </div> </div> @@ -1514,14 +1664,14 @@ <div class="method-source-code" id="days-o-source"> <pre> - <span class="ruby-comment cmt"># File lib/TjTime.rb, line 306</span> -306: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">daysTo</span>(<span class="ruby-identifier">date</span>) -307: <span class="ruby-identifier">countIntervals</span>(<span class="ruby-identifier">date</span>, <span class="ruby-value">:sameTimeNextDay</span>) -308: <span class="ruby-keyword kw">end</span></pre> + <span class="ruby-comment cmt"># File lib/TjTime.rb, line 414</span> +414: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">daysTo</span>(<span class="ruby-identifier">date</span>) +415: <span class="ruby-identifier">countIntervals</span>(<span class="ruby-identifier">date</span>, <span class="ruby-value">:sameTimeNextDay</span>) +416: <span class="ruby-keyword kw">end</span></pre> </div> </div> @@ -1550,14 +1700,14 @@ <div class="method-source-code" id="hours-ater-source"> <pre> - <span class="ruby-comment cmt"># File lib/TjTime.rb, line 225</span> -225: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">hoursLater</span>(<span class="ruby-identifier">hours</span>) -226: <span class="ruby-constant">TjTime</span>.<span class="ruby-identifier">new</span>(<span class="ruby-ivar">@time</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">hours</span> * <span class="ruby-value">3600</span>) -227: <span class="ruby-keyword kw">end</span></pre> + <span class="ruby-comment cmt"># File lib/TjTime.rb, line 333</span> +333: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">hoursLater</span>(<span class="ruby-identifier">hours</span>) +334: <span class="ruby-constant">TjTime</span>.<span class="ruby-identifier">new</span>(<span class="ruby-ivar">@time</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">hours</span> * <span class="ruby-value">3600</span>) +335: <span class="ruby-keyword kw">end</span></pre> </div> </div> @@ -1587,15 +1737,15 @@ <div class="method-source-code" id="hours-o-source"> <pre> - <span class="ruby-comment cmt"># File lib/TjTime.rb, line 299</span> -299: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">hoursTo</span>(<span class="ruby-identifier">date</span>) -300: <span class="ruby-identifier">t1</span>, <span class="ruby-identifier">t2</span> = <span class="ruby-identifier">order</span>(<span class="ruby-identifier">date</span>) -301: ((<span class="ruby-identifier">t2</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">t1</span>) <span class="ruby-operator">/</span> <span class="ruby-value">3600</span>).<span class="ruby-identifier">ceil</span> -302: <span class="ruby-keyword kw">end</span></pre> + <span class="ruby-comment cmt"># File lib/TjTime.rb, line 407</span> +407: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">hoursTo</span>(<span class="ruby-identifier">date</span>) +408: <span class="ruby-identifier">t1</span>, <span class="ruby-identifier">t2</span> = <span class="ruby-identifier">order</span>(<span class="ruby-identifier">date</span>) +409: ((<span class="ruby-identifier">t2</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">t1</span>) <span class="ruby-operator">/</span> <span class="ruby-value">3600</span>).<span class="ruby-identifier">ceil</span> +410: <span class="ruby-keyword kw">end</span></pre> </div> </div> @@ -1624,14 +1774,14 @@ <div class="method-source-code" id="method-missing-source"> <pre> - <span class="ruby-comment cmt"># File lib/TjTime.rb, line 395</span> -395: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">method_missing</span>(<span class="ruby-identifier">func</span>, *<span class="ruby-identifier">args</span>) -396: <span class="ruby-ivar">@time</span>.<span class="ruby-identifier">method</span>(<span class="ruby-identifier">func</span>).<span class="ruby-identifier">call</span>(*<span class="ruby-identifier">args</span>) -397: <span class="ruby-keyword kw">end</span></pre> + <span class="ruby-comment cmt"># File lib/TjTime.rb, line 503</span> +503: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">method_missing</span>(<span class="ruby-identifier">func</span>, *<span class="ruby-identifier">args</span>) +504: <span class="ruby-ivar">@time</span>.<span class="ruby-identifier">method</span>(<span class="ruby-identifier">func</span>).<span class="ruby-identifier">call</span>(*<span class="ruby-identifier">args</span>) +505: <span class="ruby-keyword kw">end</span></pre> </div> </div> @@ -1660,18 +1810,18 @@ <div class="method-source-code" id="midnight-source"> <pre> - <span class="ruby-comment cmt"># File lib/TjTime.rb, line 170</span> -170: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">midnight</span> -171: <span class="ruby-identifier">t</span> = <span class="ruby-ivar">@time</span>.<span class="ruby-identifier">localtime</span>.<span class="ruby-identifier">to_a</span> -172: <span class="ruby-identifier">t</span>[<span class="ruby-value">0</span>, <span class="ruby-value">3</span>] = <span class="ruby-constant">Array</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">3</span>, <span class="ruby-value">0</span>) -173: <span class="ruby-identifier">t</span>.<span class="ruby-identifier">slice!</span>(<span class="ruby-value">6</span>, <span class="ruby-value">4</span>) -174: <span class="ruby-identifier">t</span>.<span class="ruby-identifier">reverse!</span> -175: <span class="ruby-constant">TjTime</span>.<span class="ruby-identifier">new</span>(<span class="ruby-constant">Time</span>.<span class="ruby-identifier">local</span>(*<span class="ruby-identifier">t</span>)) -176: <span class="ruby-keyword kw">end</span></pre> + <span class="ruby-comment cmt"># File lib/TjTime.rb, line 278</span> +278: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">midnight</span> +279: <span class="ruby-identifier">t</span> = <span class="ruby-ivar">@time</span>.<span class="ruby-identifier">localtime</span>.<span class="ruby-identifier">to_a</span> +280: <span class="ruby-identifier">t</span>[<span class="ruby-value">0</span>, <span class="ruby-value">3</span>] = <span class="ruby-constant">Array</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">3</span>, <span class="ruby-value">0</span>) +281: <span class="ruby-identifier">t</span>.<span class="ruby-identifier">slice!</span>(<span class="ruby-value">6</span>, <span class="ruby-value">4</span>) +282: <span class="ruby-identifier">t</span>.<span class="ruby-identifier">reverse!</span> +283: <span class="ruby-constant">TjTime</span>.<span class="ruby-identifier">new</span>(<span class="ruby-constant">Time</span>.<span class="ruby-identifier">local</span>(*<span class="ruby-identifier">t</span>)) +284: <span class="ruby-keyword kw">end</span></pre> </div> </div> @@ -1701,14 +1851,14 @@ <div class="method-source-code" id="month-nd-ear-source"> <pre> - <span class="ruby-comment cmt"># File lib/TjTime.rb, line 372</span> -372: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">monthAndYear</span> -373: <span class="ruby-ivar">@time</span>.<span class="ruby-identifier">strftime</span>(<span class="ruby-value str">'%b %Y'</span>) -374: <span class="ruby-keyword kw">end</span></pre> + <span class="ruby-comment cmt"># File lib/TjTime.rb, line 480</span> +480: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">monthAndYear</span> +481: <span class="ruby-ivar">@time</span>.<span class="ruby-identifier">strftime</span>(<span class="ruby-value str">'%b %Y'</span>) +482: <span class="ruby-keyword kw">end</span></pre> </div> </div> @@ -1738,14 +1888,14 @@ <div class="method-source-code" id="months-o-source"> <pre> - <span class="ruby-comment cmt"># File lib/TjTime.rb, line 318</span> -318: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">monthsTo</span>(<span class="ruby-identifier">date</span>) -319: <span class="ruby-identifier">countIntervals</span>(<span class="ruby-identifier">date</span>, <span class="ruby-value">:sameTimeNextMonth</span>) -320: <span class="ruby-keyword kw">end</span></pre> + <span class="ruby-comment cmt"># File lib/TjTime.rb, line 426</span> +426: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">monthsTo</span>(<span class="ruby-identifier">date</span>) +427: <span class="ruby-identifier">countIntervals</span>(<span class="ruby-identifier">date</span>, <span class="ruby-value">:sameTimeNextMonth</span>) +428: <span class="ruby-keyword kw">end</span></pre> </div> </div> @@ -1778,18 +1928,18 @@ <div class="method-source-code" id="next-ay-f-eek-source"> <pre> - <span class="ruby-comment cmt"># File lib/TjTime.rb, line 386</span> -386: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">nextDayOfWeek</span>(<span class="ruby-identifier">dow</span>) -387: <span class="ruby-identifier">raise</span> <span class="ruby-value str">&quot;Day of week must be 0 - 6.&quot;</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">dow</span> <span class="ruby-operator">&gt;=</span> <span class="ruby-value">0</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">dow</span> <span class="ruby-operator">&lt;=</span> <span class="ruby-value">6</span> -388: <span class="ruby-identifier">d</span> = <span class="ruby-identifier">midnight</span>.<span class="ruby-identifier">sameTimeNextDay</span> -389: <span class="ruby-identifier">currentDoW</span> = <span class="ruby-identifier">d</span>.<span class="ruby-identifier">strftime</span>(<span class="ruby-value str">'%w'</span>).<span class="ruby-identifier">to_i</span> -390: <span class="ruby-value">1</span>.<span class="ruby-identifier">upto</span>((<span class="ruby-identifier">dow</span> <span class="ruby-operator">+</span> <span class="ruby-value">7</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">currentDoW</span>) <span class="ruby-operator">%</span> <span class="ruby-value">7</span>) { <span class="ruby-operator">|</span><span class="ruby-identifier">i</span><span class="ruby-operator">|</span> <span class="ruby-identifier">d</span> = <span class="ruby-identifier">d</span>.<span class="ruby-identifier">sameTimeNextDay</span> } -391: <span class="ruby-identifier">d</span> -392: <span class="ruby-keyword kw">end</span></pre> + <span class="ruby-comment cmt"># File lib/TjTime.rb, line 494</span> +494: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">nextDayOfWeek</span>(<span class="ruby-identifier">dow</span>) +495: <span class="ruby-identifier">raise</span> <span class="ruby-value str">&quot;Day of week must be 0 - 6.&quot;</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">dow</span> <span class="ruby-operator">&gt;=</span> <span class="ruby-value">0</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">dow</span> <span class="ruby-operator">&lt;=</span> <span class="ruby-value">6</span> +496: <span class="ruby-identifier">d</span> = <span class="ruby-identifier">midnight</span>.<span class="ruby-identifier">sameTimeNextDay</span> +497: <span class="ruby-identifier">currentDoW</span> = <span class="ruby-identifier">d</span>.<span class="ruby-identifier">strftime</span>(<span class="ruby-value str">'%w'</span>).<span class="ruby-identifier">to_i</span> +498: <span class="ruby-value">1</span>.<span class="ruby-identifier">upto</span>((<span class="ruby-identifier">dow</span> <span class="ruby-operator">+</span> <span class="ruby-value">7</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">currentDoW</span>) <span class="ruby-operator">%</span> <span class="ruby-value">7</span>) { <span class="ruby-operator">|</span><span class="ruby-identifier">i</span><span class="ruby-operator">|</span> <span class="ruby-identifier">d</span> = <span class="ruby-identifier">d</span>.<span class="ruby-identifier">sameTimeNextDay</span> } +499: <span class="ruby-identifier">d</span> +500: <span class="ruby-keyword kw">end</span></pre> </div> </div> @@ -1818,14 +1968,14 @@ <div class="method-source-code" id="quarter-ame-source"> <pre> - <span class="ruby-comment cmt"># File lib/TjTime.rb, line 361</span> -361: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">quarterName</span> -362: <span class="ruby-node">&quot;Q#{(@time.mon / 3) + 1}&quot;</span> -363: <span class="ruby-keyword kw">end</span></pre> + <span class="ruby-comment cmt"># File lib/TjTime.rb, line 469</span> +469: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">quarterName</span> +470: <span class="ruby-node">&quot;Q#{(@time.mon / 3) + 1}&quot;</span> +471: <span class="ruby-keyword kw">end</span></pre> </div> </div> @@ -1855,14 +2005,14 @@ <div class="method-source-code" id="quarters-o-source"> <pre> - <span class="ruby-comment cmt"># File lib/TjTime.rb, line 324</span> -324: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">quartersTo</span>(<span class="ruby-identifier">date</span>) -325: <span class="ruby-identifier">countIntervals</span>(<span class="ruby-identifier">date</span>, <span class="ruby-value">:sameTimeNextQuarter</span>) -326: <span class="ruby-keyword kw">end</span></pre> + <span class="ruby-comment cmt"># File lib/TjTime.rb, line 432</span> +432: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">quartersTo</span>(<span class="ruby-identifier">date</span>) +433: <span class="ruby-identifier">countIntervals</span>(<span class="ruby-identifier">date</span>, <span class="ruby-value">:sameTimeNextQuarter</span>) +434: <span class="ruby-keyword kw">end</span></pre> </div> </div> @@ -1892,21 +2042,21 @@ <div class="method-source-code" id="same-ime-ext-ay-source"> <pre> - <span class="ruby-comment cmt"># File lib/TjTime.rb, line 236</span> -236: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">sameTimeNextDay</span> -237: <span class="ruby-identifier">delta</span> = [ <span class="ruby-value">0</span>, <span class="ruby-value">1</span>, <span class="ruby-value">1</span> ] -238: <span class="ruby-identifier">localT1</span> = <span class="ruby-ivar">@time</span>.<span class="ruby-identifier">localtime</span>.<span class="ruby-identifier">to_a</span> -239: <span class="ruby-identifier">delta</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">d</span><span class="ruby-operator">|</span> -240: <span class="ruby-identifier">t</span> = <span class="ruby-ivar">@time</span> <span class="ruby-operator">+</span> (<span class="ruby-value">24</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">d</span>) * <span class="ruby-value">60</span> * <span class="ruby-value">60</span> -241: <span class="ruby-identifier">localT2</span> = <span class="ruby-identifier">t</span>.<span class="ruby-identifier">localtime</span>.<span class="ruby-identifier">to_a</span> -242: <span class="ruby-keyword kw">return</span> <span class="ruby-constant">TjTime</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">t</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">localT1</span>[<span class="ruby-value">0</span>, <span class="ruby-value">3</span>] <span class="ruby-operator">==</span> <span class="ruby-identifier">localT2</span>[<span class="ruby-value">0</span>, <span class="ruby-value">3</span>] -243: <span class="ruby-keyword kw">end</span> -244: <span class="ruby-identifier">raise</span> <span class="ruby-node">&quot;Algorithm is broken for #{@time}&quot;</span> -245: <span class="ruby-keyword kw">end</span></pre> + <span class="ruby-comment cmt"># File lib/TjTime.rb, line 344</span> +344: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">sameTimeNextDay</span> +345: <span class="ruby-identifier">delta</span> = [ <span class="ruby-value">0</span>, <span class="ruby-value">1</span>, <span class="ruby-value">1</span> ] +346: <span class="ruby-identifier">localT1</span> = <span class="ruby-ivar">@time</span>.<span class="ruby-identifier">localtime</span>.<span class="ruby-identifier">to_a</span> +347: <span class="ruby-identifier">delta</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">d</span><span class="ruby-operator">|</span> +348: <span class="ruby-identifier">t</span> = <span class="ruby-ivar">@time</span> <span class="ruby-operator">+</span> (<span class="ruby-value">24</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">d</span>) * <span class="ruby-value">60</span> * <span class="ruby-value">60</span> +349: <span class="ruby-identifier">localT2</span> = <span class="ruby-identifier">t</span>.<span class="ruby-identifier">localtime</span>.<span class="ruby-identifier">to_a</span> +350: <span class="ruby-keyword kw">return</span> <span class="ruby-constant">TjTime</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">t</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">localT1</span>[<span class="ruby-value">0</span>, <span class="ruby-value">3</span>] <span class="ruby-operator">==</span> <span class="ruby-identifier">localT2</span>[<span class="ruby-value">0</span>, <span class="ruby-value">3</span>] +351: <span class="ruby-keyword kw">end</span> +352: <span class="ruby-identifier">raise</span> <span class="ruby-node">&quot;Algorithm is broken for #{@time}&quot;</span> +353: <span class="ruby-keyword kw">end</span></pre> </div> </div> @@ -1935,14 +2085,14 @@ <div class="method-source-code" id="same-ime-ext-our-source"> <pre> - <span class="ruby-comment cmt"># File lib/TjTime.rb, line 230</span> -230: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">sameTimeNextHour</span> -231: <span class="ruby-identifier">hoursLater</span>(<span class="ruby-value">1</span>) -232: <span class="ruby-keyword kw">end</span></pre> + <span class="ruby-comment cmt"># File lib/TjTime.rb, line 338</span> +338: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">sameTimeNextHour</span> +339: <span class="ruby-identifier">hoursLater</span>(<span class="ruby-value">1</span>) +340: <span class="ruby-keyword kw">end</span></pre> </div> </div> @@ -1972,22 +2122,22 @@ <div class="method-source-code" id="same-ime-ext-onth-source"> <pre> - <span class="ruby-comment cmt"># File lib/TjTime.rb, line 262</span> -262: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">sameTimeNextMonth</span> -263: <span class="ruby-identifier">sec</span>, <span class="ruby-identifier">min</span>, <span class="ruby-identifier">hour</span>, <span class="ruby-identifier">day</span>, <span class="ruby-identifier">month</span>, <span class="ruby-identifier">year</span> = <span class="ruby-ivar">@time</span>.<span class="ruby-identifier">localtime</span>.<span class="ruby-identifier">to_a</span> -264: <span class="ruby-identifier">monMax</span> = <span class="ruby-identifier">month</span> <span class="ruby-operator">==</span> <span class="ruby-value">2</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">leapYear?</span>(<span class="ruby-identifier">year</span>) <span class="ruby-operator">?</span> <span class="ruby-value">29</span> <span class="ruby-operator">:</span> <span class="ruby-constant">MON_MAX</span>[<span class="ruby-identifier">month</span>] -265: <span class="ruby-identifier">month</span> <span class="ruby-operator">+=</span> <span class="ruby-value">1</span> -266: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">month</span> <span class="ruby-operator">&gt;</span> <span class="ruby-value">12</span> -267: <span class="ruby-identifier">month</span> = <span class="ruby-value">1</span> -268: <span class="ruby-identifier">year</span> <span class="ruby-operator">+=</span> <span class="ruby-value">1</span> -269: <span class="ruby-keyword kw">end</span> -270: <span class="ruby-identifier">day</span> = <span class="ruby-identifier">monMax</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">day</span> <span class="ruby-operator">&gt;=</span> <span class="ruby-identifier">monMax</span> -271: <span class="ruby-constant">TjTime</span>.<span class="ruby-identifier">new</span>(<span class="ruby-constant">Time</span>.<span class="ruby-identifier">mktime</span>(<span class="ruby-identifier">year</span>, <span class="ruby-identifier">month</span>, <span class="ruby-identifier">day</span>, <span class="ruby-identifier">hour</span>, <span class="ruby-identifier">min</span>, <span class="ruby-identifier">sec</span>, <span class="ruby-value">0</span>)) -272: <span class="ruby-keyword kw">end</span></pre> + <span class="ruby-comment cmt"># File lib/TjTime.rb, line 370</span> +370: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">sameTimeNextMonth</span> +371: <span class="ruby-identifier">sec</span>, <span class="ruby-identifier">min</span>, <span class="ruby-identifier">hour</span>, <span class="ruby-identifier">day</span>, <span class="ruby-identifier">month</span>, <span class="ruby-identifier">year</span> = <span class="ruby-ivar">@time</span>.<span class="ruby-identifier">localtime</span>.<span class="ruby-identifier">to_a</span> +372: <span class="ruby-identifier">monMax</span> = <span class="ruby-identifier">month</span> <span class="ruby-operator">==</span> <span class="ruby-value">2</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">leapYear?</span>(<span class="ruby-identifier">year</span>) <span class="ruby-operator">?</span> <span class="ruby-value">29</span> <span class="ruby-operator">:</span> <span class="ruby-constant">MON_MAX</span>[<span class="ruby-identifier">month</span>] +373: <span class="ruby-identifier">month</span> <span class="ruby-operator">+=</span> <span class="ruby-value">1</span> +374: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">month</span> <span class="ruby-operator">&gt;</span> <span class="ruby-value">12</span> +375: <span class="ruby-identifier">month</span> = <span class="ruby-value">1</span> +376: <span class="ruby-identifier">year</span> <span class="ruby-operator">+=</span> <span class="ruby-value">1</span> +377: <span class="ruby-keyword kw">end</span> +378: <span class="ruby-identifier">day</span> = <span class="ruby-identifier">monMax</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">day</span> <span class="ruby-operator">&gt;=</span> <span class="ruby-identifier">monMax</span> +379: <span class="ruby-constant">TjTime</span>.<span class="ruby-identifier">new</span>(<span class="ruby-constant">Time</span>.<span class="ruby-identifier">mktime</span>(<span class="ruby-identifier">year</span>, <span class="ruby-identifier">month</span>, <span class="ruby-identifier">day</span>, <span class="ruby-identifier">hour</span>, <span class="ruby-identifier">min</span>, <span class="ruby-identifier">sec</span>, <span class="ruby-value">0</span>)) +380: <span class="ruby-keyword kw">end</span></pre> </div> </div> @@ -2017,21 +2167,21 @@ <div class="method-source-code" id="same-ime-ext-uarter-source"> <pre> - <span class="ruby-comment cmt"># File lib/TjTime.rb, line 276</span> -276: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">sameTimeNextQuarter</span> -277: <span class="ruby-identifier">t</span> = <span class="ruby-ivar">@time</span>.<span class="ruby-identifier">localtime</span>.<span class="ruby-identifier">to_a</span> -278: <span class="ruby-keyword kw">if</span> (<span class="ruby-identifier">t</span>[<span class="ruby-value">4</span>] <span class="ruby-operator">+=</span> <span class="ruby-value">3</span>) <span class="ruby-operator">&gt;</span> <span class="ruby-value">12</span> -279: <span class="ruby-identifier">t</span>[<span class="ruby-value">4</span>] <span class="ruby-operator">-=</span> <span class="ruby-value">12</span> -280: <span class="ruby-identifier">t</span>[<span class="ruby-value">5</span>] <span class="ruby-operator">+=</span> <span class="ruby-value">1</span> -281: <span class="ruby-keyword kw">end</span> -282: <span class="ruby-identifier">t</span>.<span class="ruby-identifier">slice!</span>(<span class="ruby-value">6</span>, <span class="ruby-value">4</span>) -283: <span class="ruby-identifier">t</span>.<span class="ruby-identifier">reverse!</span> -284: <span class="ruby-constant">TjTime</span>.<span class="ruby-identifier">new</span>(<span class="ruby-constant">Time</span>.<span class="ruby-identifier">local</span>(*<span class="ruby-identifier">t</span>)) -285: <span class="ruby-keyword kw">end</span></pre> + <span class="ruby-comment cmt"># File lib/TjTime.rb, line 384</span> +384: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">sameTimeNextQuarter</span> +385: <span class="ruby-identifier">t</span> = <span class="ruby-ivar">@time</span>.<span class="ruby-identifier">localtime</span>.<span class="ruby-identifier">to_a</span> +386: <span class="ruby-keyword kw">if</span> (<span class="ruby-identifier">t</span>[<span class="ruby-value">4</span>] <span class="ruby-operator">+=</span> <span class="ruby-value">3</span>) <span class="ruby-operator">&gt;</span> <span class="ruby-value">12</span> +387: <span class="ruby-identifier">t</span>[<span class="ruby-value">4</span>] <span class="ruby-operator">-=</span> <span class="ruby-value">12</span> +388: <span class="ruby-identifier">t</span>[<span class="ruby-value">5</span>] <span class="ruby-operator">+=</span> <span class="ruby-value">1</span> +389: <span class="ruby-keyword kw">end</span> +390: <span class="ruby-identifier">t</span>.<span class="ruby-identifier">slice!</span>(<span class="ruby-value">6</span>, <span class="ruby-value">4</span>) +391: <span class="ruby-identifier">t</span>.<span class="ruby-identifier">reverse!</span> +392: <span class="ruby-constant">TjTime</span>.<span class="ruby-identifier">new</span>(<span class="ruby-constant">Time</span>.<span class="ruby-identifier">local</span>(*<span class="ruby-identifier">t</span>)) +393: <span class="ruby-keyword kw">end</span></pre> </div> </div> @@ -2061,21 +2211,21 @@ <div class="method-source-code" id="same-ime-ext-eek-source"> <pre> - <span class="ruby-comment cmt"># File lib/TjTime.rb, line 249</span> -249: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">sameTimeNextWeek</span> -250: <span class="ruby-identifier">delta</span> = [ <span class="ruby-value">0</span>, <span class="ruby-value">1</span>, <span class="ruby-value">1</span> ] -251: <span class="ruby-identifier">localT1</span> = <span class="ruby-ivar">@time</span>.<span class="ruby-identifier">localtime</span>.<span class="ruby-identifier">to_a</span> -252: <span class="ruby-identifier">delta</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">d</span><span class="ruby-operator">|</span> -253: <span class="ruby-identifier">t</span> = <span class="ruby-ivar">@time</span> <span class="ruby-operator">+</span> (<span class="ruby-value">7</span> * <span class="ruby-value">24</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">d</span>) * <span class="ruby-value">60</span> * <span class="ruby-value">60</span> -254: <span class="ruby-identifier">localT2</span> = <span class="ruby-identifier">t</span>.<span class="ruby-identifier">localtime</span>.<span class="ruby-identifier">to_a</span> -255: <span class="ruby-keyword kw">return</span> <span class="ruby-constant">TjTime</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">t</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">localT1</span>[<span class="ruby-value">0</span>, <span class="ruby-value">3</span>] <span class="ruby-operator">==</span> <span class="ruby-identifier">localT2</span>[<span class="ruby-value">0</span>, <span class="ruby-value">3</span>] -256: <span class="ruby-keyword kw">end</span> -257: <span class="ruby-identifier">raise</span> <span class="ruby-node">&quot;Algorithm is broken for #{@time}&quot;</span> -258: <span class="ruby-keyword kw">end</span></pre> + <span class="ruby-comment cmt"># File lib/TjTime.rb, line 357</span> +357: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">sameTimeNextWeek</span> +358: <span class="ruby-identifier">delta</span> = [ <span class="ruby-value">0</span>, <span class="ruby-value">1</span>, <span class="ruby-value">1</span> ] +359: <span class="ruby-identifier">localT1</span> = <span class="ruby-ivar">@time</span>.<span class="ruby-identifier">localtime</span>.<span class="ruby-identifier">to_a</span> +360: <span class="ruby-identifier">delta</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">d</span><span class="ruby-operator">|</span> +361: <span class="ruby-identifier">t</span> = <span class="ruby-ivar">@time</span> <span class="ruby-operator">+</span> (<span class="ruby-value">7</span> * <span class="ruby-value">24</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">d</span>) * <span class="ruby-value">60</span> * <span class="ruby-value">60</span> +362: <span class="ruby-identifier">localT2</span> = <span class="ruby-identifier">t</span>.<span class="ruby-identifier">localtime</span>.<span class="ruby-identifier">to_a</span> +363: <span class="ruby-keyword kw">return</span> <span class="ruby-constant">TjTime</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">t</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">localT1</span>[<span class="ruby-value">0</span>, <span class="ruby-value">3</span>] <span class="ruby-operator">==</span> <span class="ruby-identifier">localT2</span>[<span class="ruby-value">0</span>, <span class="ruby-value">3</span>] +364: <span class="ruby-keyword kw">end</span> +365: <span class="ruby-identifier">raise</span> <span class="ruby-node">&quot;Algorithm is broken for #{@time}&quot;</span> +366: <span class="ruby-keyword kw">end</span></pre> </div> </div> @@ -2105,18 +2255,18 @@ <div class="method-source-code" id="same-ime-ext-ear-source"> <pre> - <span class="ruby-comment cmt"># File lib/TjTime.rb, line 289</span> -289: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">sameTimeNextYear</span> -290: <span class="ruby-identifier">t</span> = <span class="ruby-ivar">@time</span>.<span class="ruby-identifier">localtime</span>.<span class="ruby-identifier">to_a</span> -291: <span class="ruby-identifier">t</span>[<span class="ruby-value">5</span>] <span class="ruby-operator">+=</span> <span class="ruby-value">1</span> -292: <span class="ruby-identifier">t</span>.<span class="ruby-identifier">slice!</span>(<span class="ruby-value">6</span>, <span class="ruby-value">4</span>) -293: <span class="ruby-identifier">t</span>.<span class="ruby-identifier">reverse!</span> -294: <span class="ruby-constant">TjTime</span>.<span class="ruby-identifier">new</span>(<span class="ruby-constant">Time</span>.<span class="ruby-identifier">local</span>(*<span class="ruby-identifier">t</span>)) -295: <span class="ruby-keyword kw">end</span></pre> + <span class="ruby-comment cmt"># File lib/TjTime.rb, line 397</span> +397: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">sameTimeNextYear</span> +398: <span class="ruby-identifier">t</span> = <span class="ruby-ivar">@time</span>.<span class="ruby-identifier">localtime</span>.<span class="ruby-identifier">to_a</span> +399: <span class="ruby-identifier">t</span>[<span class="ruby-value">5</span>] <span class="ruby-operator">+=</span> <span class="ruby-value">1</span> +400: <span class="ruby-identifier">t</span>.<span class="ruby-identifier">slice!</span>(<span class="ruby-value">6</span>, <span class="ruby-value">4</span>) +401: <span class="ruby-identifier">t</span>.<span class="ruby-identifier">reverse!</span> +402: <span class="ruby-constant">TjTime</span>.<span class="ruby-identifier">new</span>(<span class="ruby-constant">Time</span>.<span class="ruby-identifier">local</span>(*<span class="ruby-identifier">t</span>)) +403: <span class="ruby-keyword kw">end</span></pre> </div> </div> @@ -2146,15 +2296,15 @@ <div class="method-source-code" id="seconds-f-ay-source"> <pre> - <span class="ruby-comment cmt"># File lib/TjTime.rb, line 94</span> -94: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">secondsOfDay</span>(<span class="ruby-identifier">tz</span> = <span class="ruby-keyword kw">nil</span>) -95: <span class="ruby-comment cmt"># TODO: Add timezone support</span> -96: (<span class="ruby-ivar">@time</span>.<span class="ruby-identifier">to_i</span> <span class="ruby-operator">+</span> <span class="ruby-ivar">@time</span>.<span class="ruby-identifier">gmt_offset</span>) <span class="ruby-operator">%</span> (<span class="ruby-value">60</span> * <span class="ruby-value">60</span> * <span class="ruby-value">24</span>) -97: <span class="ruby-keyword kw">end</span></pre> + <span class="ruby-comment cmt"># File lib/TjTime.rb, line 202</span> +202: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">secondsOfDay</span>(<span class="ruby-identifier">tz</span> = <span class="ruby-keyword kw">nil</span>) +203: <span class="ruby-comment cmt"># TODO: Add timezone support</span> +204: (<span class="ruby-ivar">@time</span>.<span class="ruby-identifier">to_i</span> <span class="ruby-operator">+</span> <span class="ruby-ivar">@time</span>.<span class="ruby-identifier">gmt_offset</span>) <span class="ruby-operator">%</span> (<span class="ruby-value">60</span> * <span class="ruby-value">60</span> * <span class="ruby-value">24</span>) +205: <span class="ruby-keyword kw">end</span></pre> </div> </div> @@ -2183,14 +2333,14 @@ <div class="method-source-code" id="short-onth-ame-source"> <pre> - <span class="ruby-comment cmt"># File lib/TjTime.rb, line 356</span> -356: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">shortMonthName</span> -357: <span class="ruby-ivar">@time</span>.<span class="ruby-identifier">strftime</span>(<span class="ruby-value str">'%b'</span>) -358: <span class="ruby-keyword kw">end</span></pre> + <span class="ruby-comment cmt"># File lib/TjTime.rb, line 464</span> +464: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">shortMonthName</span> +465: <span class="ruby-ivar">@time</span>.<span class="ruby-identifier">strftime</span>(<span class="ruby-value str">'%b'</span>) +466: <span class="ruby-keyword kw">end</span></pre> </div> </div> @@ -2217,14 +2367,14 @@ <div class="method-source-code" id="to-ary-source"> <pre> - <span class="ruby-comment cmt"># File lib/TjTime.rb, line 350</span> -350: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">to_ary</span> -351: <span class="ruby-identifier">to_s</span> -352: <span class="ruby-keyword kw">end</span></pre> + <span class="ruby-comment cmt"># File lib/TjTime.rb, line 458</span> +458: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">to_ary</span> +459: <span class="ruby-identifier">to_s</span> +460: <span class="ruby-keyword kw">end</span></pre> </div> </div> @@ -2253,14 +2403,14 @@ <div class="method-source-code" id="to-i-source"> <pre> - <span class="ruby-comment cmt"># File lib/TjTime.rb, line 346</span> -346: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">to_i</span> -347: <span class="ruby-ivar">@time</span>.<span class="ruby-identifier">to_i</span> -348: <span class="ruby-keyword kw">end</span></pre> + <span class="ruby-comment cmt"># File lib/TjTime.rb, line 454</span> +454: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">to_i</span> +455: <span class="ruby-ivar">@time</span>.<span class="ruby-identifier">to_i</span> +456: <span class="ruby-keyword kw">end</span></pre> </div> </div> @@ -2290,19 +2440,19 @@ <div class="method-source-code" id="to-s-source"> <pre> - <span class="ruby-comment cmt"># File lib/TjTime.rb, line 336</span> -336: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">to_s</span>(<span class="ruby-identifier">format</span> = <span class="ruby-keyword kw">nil</span>) -337: <span class="ruby-keyword kw">return</span> <span class="ruby-value str">'unknown'</span> <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@time</span>.<span class="ruby-identifier">nil?</span> -338: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">format</span>.<span class="ruby-identifier">nil?</span> -339: <span class="ruby-identifier">format</span> = <span class="ruby-value str">'%Y-%m-%d-%H:%M'</span> <span class="ruby-operator">+</span> (<span class="ruby-ivar">@time</span>.<span class="ruby-identifier">sec</span> <span class="ruby-operator">==</span> <span class="ruby-value">0</span> <span class="ruby-operator">?</span> <span class="ruby-value str">''</span> <span class="ruby-operator">:</span> <span class="ruby-value str">':%S'</span>) <span class="ruby-operator">+</span> <span class="ruby-value str">'-%z'</span> -340: <span class="ruby-keyword kw">end</span> -341: <span class="ruby-comment cmt"># Always report values in local timezone</span> -342: <span class="ruby-ivar">@time</span>.<span class="ruby-identifier">dup</span>.<span class="ruby-identifier">localtime</span>.<span class="ruby-identifier">strftime</span>(<span class="ruby-identifier">format</span>) -343: <span class="ruby-keyword kw">end</span></pre> + <span class="ruby-comment cmt"># File lib/TjTime.rb, line 444</span> +444: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">to_s</span>(<span class="ruby-identifier">format</span> = <span class="ruby-keyword kw">nil</span>) +445: <span class="ruby-keyword kw">return</span> <span class="ruby-value str">'unknown'</span> <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@time</span>.<span class="ruby-identifier">nil?</span> +446: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">format</span>.<span class="ruby-identifier">nil?</span> +447: <span class="ruby-identifier">format</span> = <span class="ruby-value str">'%Y-%m-%d-%H:%M'</span> <span class="ruby-operator">+</span> (<span class="ruby-ivar">@time</span>.<span class="ruby-identifier">sec</span> <span class="ruby-operator">==</span> <span class="ruby-value">0</span> <span class="ruby-operator">?</span> <span class="ruby-value str">''</span> <span class="ruby-operator">:</span> <span class="ruby-value str">':%S'</span>) <span class="ruby-operator">+</span> <span class="ruby-value str">'-%z'</span> +448: <span class="ruby-keyword kw">end</span> +449: <span class="ruby-comment cmt"># Always report values in local timezone</span> +450: <span class="ruby-ivar">@time</span>.<span class="ruby-identifier">dup</span>.<span class="ruby-identifier">localtime</span>.<span class="ruby-identifier">strftime</span>(<span class="ruby-identifier">format</span>) +451: <span class="ruby-keyword kw">end</span></pre> </div> </div> @@ -2332,18 +2482,18 @@ <div class="method-source-code" id="upto-source"> <pre> - <span class="ruby-comment cmt"># File lib/TjTime.rb, line 152</span> -152: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">upto</span>(<span class="ruby-identifier">endDate</span>, <span class="ruby-identifier">step</span> = <span class="ruby-value">1</span>) -153: <span class="ruby-identifier">t</span> = <span class="ruby-ivar">@time</span> -154: <span class="ruby-keyword kw">while</span> <span class="ruby-identifier">t</span> <span class="ruby-operator">&lt;</span> <span class="ruby-identifier">endDate</span>.<span class="ruby-identifier">time</span> -155: <span class="ruby-keyword kw">yield</span>(<span class="ruby-constant">TjTime</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">t</span>)) -156: <span class="ruby-identifier">t</span> <span class="ruby-operator">+=</span> <span class="ruby-identifier">step</span> -157: <span class="ruby-keyword kw">end</span> -158: <span class="ruby-keyword kw">end</span></pre> + <span class="ruby-comment cmt"># File lib/TjTime.rb, line 260</span> +260: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">upto</span>(<span class="ruby-identifier">endDate</span>, <span class="ruby-identifier">step</span> = <span class="ruby-value">1</span>) +261: <span class="ruby-identifier">t</span> = <span class="ruby-ivar">@time</span> +262: <span class="ruby-keyword kw">while</span> <span class="ruby-identifier">t</span> <span class="ruby-operator">&lt;</span> <span class="ruby-identifier">endDate</span>.<span class="ruby-identifier">time</span> +263: <span class="ruby-keyword kw">yield</span>(<span class="ruby-constant">TjTime</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">t</span>)) +264: <span class="ruby-identifier">t</span> <span class="ruby-operator">+=</span> <span class="ruby-identifier">step</span> +265: <span class="ruby-keyword kw">end</span> +266: <span class="ruby-keyword kw">end</span></pre> </div> </div> @@ -2373,14 +2523,14 @@ <div class="method-source-code" id="week-source"> <pre> - <span class="ruby-comment cmt"># File lib/TjTime.rb, line 367</span> -367: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">week</span>(<span class="ruby-identifier">weekStartsMonday</span>) -368: <span class="ruby-ivar">@time</span>.<span class="ruby-identifier">strftime</span>(<span class="ruby-identifier">weekStartsMonday</span> <span class="ruby-operator">?</span> <span class="ruby-value str">'%W'</span> <span class="ruby-operator">:</span> <span class="ruby-value str">'%U'</span>) -369: <span class="ruby-keyword kw">end</span></pre> + <span class="ruby-comment cmt"># File lib/TjTime.rb, line 475</span> +475: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">week</span>(<span class="ruby-identifier">weekStartsMonday</span>) +476: <span class="ruby-ivar">@time</span>.<span class="ruby-identifier">strftime</span>(<span class="ruby-identifier">weekStartsMonday</span> <span class="ruby-operator">?</span> <span class="ruby-value str">'%W'</span> <span class="ruby-operator">:</span> <span class="ruby-value str">'%U'</span>) +477: <span class="ruby-keyword kw">end</span></pre> </div> </div> @@ -2410,14 +2560,14 @@ <div class="method-source-code" id="weekday-nd-ate-source"> <pre> - <span class="ruby-comment cmt"># File lib/TjTime.rb, line 377</span> -377: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">weekdayAndDate</span> -378: <span class="ruby-ivar">@time</span>.<span class="ruby-identifier">strftime</span>(<span class="ruby-value str">'%A %Y-%m-%d'</span>) -379: <span class="ruby-keyword kw">end</span></pre> + <span class="ruby-comment cmt"># File lib/TjTime.rb, line 485</span> +485: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">weekdayAndDate</span> +486: <span class="ruby-ivar">@time</span>.<span class="ruby-identifier">strftime</span>(<span class="ruby-value str">'%A %Y-%m-%d'</span>) +487: <span class="ruby-keyword kw">end</span></pre> </div> </div> @@ -2447,14 +2597,14 @@ <div class="method-source-code" id="weeks-o-source"> <pre> - <span class="ruby-comment cmt"># File lib/TjTime.rb, line 312</span> -312: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">weeksTo</span>(<span class="ruby-identifier">date</span>) -313: <span class="ruby-identifier">countIntervals</span>(<span class="ruby-identifier">date</span>, <span class="ruby-value">:sameTimeNextWeek</span>) -314: <span class="ruby-keyword kw">end</span></pre> + <span class="ruby-comment cmt"># File lib/TjTime.rb, line 420</span> +420: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">weeksTo</span>(<span class="ruby-identifier">date</span>) +421: <span class="ruby-identifier">countIntervals</span>(<span class="ruby-identifier">date</span>, <span class="ruby-value">:sameTimeNextWeek</span>) +422: <span class="ruby-keyword kw">end</span></pre> </div> </div> @@ -2484,14 +2634,14 @@ <div class="method-source-code" id="years-o-source"> <pre> - <span class="ruby-comment cmt"># File lib/TjTime.rb, line 330</span> -330: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">yearsTo</span>(<span class="ruby-identifier">date</span>) -331: <span class="ruby-identifier">countIntervals</span>(<span class="ruby-identifier">date</span>, <span class="ruby-value">:sameTimeNextYear</span>) -332: <span class="ruby-keyword kw">end</span></pre> + <span class="ruby-comment cmt"># File lib/TjTime.rb, line 438</span> +438: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">yearsTo</span>(<span class="ruby-identifier">date</span>) +439: <span class="ruby-identifier">countIntervals</span>(<span class="ruby-identifier">date</span>, <span class="ruby-value">:sameTimeNextYear</span>) +440: <span class="ruby-keyword kw">end</span></pre> </div> </div> @@ -2524,20 +2674,20 @@ <div class="method-source-code" id="count-ntervals-source"> <pre> - <span class="ruby-comment cmt"># File lib/TjTime.rb, line 412</span> -412: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">countIntervals</span>(<span class="ruby-identifier">date</span>, <span class="ruby-identifier">stepFunc</span>) -413: <span class="ruby-identifier">i</span> = <span class="ruby-value">0</span> -414: <span class="ruby-identifier">t1</span>, <span class="ruby-identifier">t2</span> = <span class="ruby-identifier">order</span>(<span class="ruby-identifier">date</span>) -415: <span class="ruby-keyword kw">while</span> <span class="ruby-identifier">t1</span> <span class="ruby-operator">&lt;</span> <span class="ruby-identifier">t2</span> -416: <span class="ruby-identifier">t1</span> = <span class="ruby-identifier">t1</span>.<span class="ruby-identifier">send</span>(<span class="ruby-identifier">stepFunc</span>) -417: <span class="ruby-identifier">i</span> <span class="ruby-operator">+=</span> <span class="ruby-value">1</span> -418: <span class="ruby-keyword kw">end</span> -419: <span class="ruby-identifier">i</span> -420: <span class="ruby-keyword kw">end</span></pre> + <span class="ruby-comment cmt"># File lib/TjTime.rb, line 520</span> +520: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">countIntervals</span>(<span class="ruby-identifier">date</span>, <span class="ruby-identifier">stepFunc</span>) +521: <span class="ruby-identifier">i</span> = <span class="ruby-value">0</span> +522: <span class="ruby-identifier">t1</span>, <span class="ruby-identifier">t2</span> = <span class="ruby-identifier">order</span>(<span class="ruby-identifier">date</span>) +523: <span class="ruby-keyword kw">while</span> <span class="ruby-identifier">t1</span> <span class="ruby-operator">&lt;</span> <span class="ruby-identifier">t2</span> +524: <span class="ruby-identifier">t1</span> = <span class="ruby-identifier">t1</span>.<span class="ruby-identifier">send</span>(<span class="ruby-identifier">stepFunc</span>) +525: <span class="ruby-identifier">i</span> <span class="ruby-operator">+=</span> <span class="ruby-value">1</span> +526: <span class="ruby-keyword kw">end</span> +527: <span class="ruby-identifier">i</span> +528: <span class="ruby-keyword kw">end</span></pre> </div> </div> @@ -2564,21 +2714,21 @@ <div class="method-source-code" id="leap-ear--source"> <pre> - <span class="ruby-comment cmt"># File lib/TjTime.rb, line 422</span> -422: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">leapYear?</span>(<span class="ruby-identifier">year</span>) -423: <span class="ruby-keyword kw">case</span> -424: <span class="ruby-keyword kw">when</span> <span class="ruby-identifier">year</span> <span class="ruby-operator">%</span> <span class="ruby-value">400</span> <span class="ruby-operator">==</span> <span class="ruby-value">0</span> -425: <span class="ruby-keyword kw">true</span> -426: <span class="ruby-keyword kw">when</span> <span class="ruby-identifier">year</span> <span class="ruby-operator">%</span> <span class="ruby-value">100</span> <span class="ruby-operator">==</span> <span class="ruby-value">0</span> -427: <span class="ruby-keyword kw">false</span> -428: <span class="ruby-keyword kw">else</span> -429: <span class="ruby-identifier">year</span> <span class="ruby-operator">%</span> <span class="ruby-value">4</span> <span class="ruby-operator">==</span> <span class="ruby-value">0</span> -430: <span class="ruby-keyword kw">end</span> -431: <span class="ruby-keyword kw">end</span></pre> + <span class="ruby-comment cmt"># File lib/TjTime.rb, line 530</span> +530: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">leapYear?</span>(<span class="ruby-identifier">year</span>) +531: <span class="ruby-keyword kw">case</span> +532: <span class="ruby-keyword kw">when</span> <span class="ruby-identifier">year</span> <span class="ruby-operator">%</span> <span class="ruby-value">400</span> <span class="ruby-operator">==</span> <span class="ruby-value">0</span> +533: <span class="ruby-keyword kw">true</span> +534: <span class="ruby-keyword kw">when</span> <span class="ruby-identifier">year</span> <span class="ruby-operator">%</span> <span class="ruby-value">100</span> <span class="ruby-operator">==</span> <span class="ruby-value">0</span> +535: <span class="ruby-keyword kw">false</span> +536: <span class="ruby-keyword kw">else</span> +537: <span class="ruby-identifier">year</span> <span class="ruby-operator">%</span> <span class="ruby-value">4</span> <span class="ruby-operator">==</span> <span class="ruby-value">0</span> +538: <span class="ruby-keyword kw">end</span> +539: <span class="ruby-keyword kw">end</span></pre> </div> </div> @@ -2605,20 +2755,20 @@ <div class="method-source-code" id="order-source"> <pre> - <span class="ruby-comment cmt"># File lib/TjTime.rb, line 401</span> -401: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">order</span>(<span class="ruby-identifier">date</span>) -402: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">date</span>.<span class="ruby-identifier">time</span> <span class="ruby-operator">&lt;</span> <span class="ruby-ivar">@time</span> -403: <span class="ruby-identifier">t1</span> = <span class="ruby-identifier">date</span> -404: <span class="ruby-identifier">t2</span> = <span class="ruby-keyword kw">self</span> -405: <span class="ruby-keyword kw">else</span> -406: <span class="ruby-identifier">t1</span> = <span class="ruby-keyword kw">self</span> -407: <span class="ruby-identifier">t2</span> = <span class="ruby-identifier">date</span> -408: <span class="ruby-keyword kw">end</span> -409: [ <span class="ruby-identifier">t1</span>, <span class="ruby-identifier">t2</span> ] -410: <span class="ruby-keyword kw">end</span></pre> + <span class="ruby-comment cmt"># File lib/TjTime.rb, line 509</span> +509: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">order</span>(<span class="ruby-identifier">date</span>) +510: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">date</span>.<span class="ruby-identifier">time</span> <span class="ruby-operator">&lt;</span> <span class="ruby-ivar">@time</span> +511: <span class="ruby-identifier">t1</span> = <span class="ruby-identifier">date</span> +512: <span class="ruby-identifier">t2</span> = <span class="ruby-keyword kw">self</span> +513: <span class="ruby-keyword kw">else</span> +514: <span class="ruby-identifier">t1</span> = <span class="ruby-keyword kw">self</span> +515: <span class="ruby-identifier">t2</span> = <span class="ruby-identifier">date</span> +516: <span class="ruby-keyword kw">end</span> +517: [ <span class="ruby-identifier">t1</span>, <span class="ruby-identifier">t2</span> ] +518: <span class="ruby-keyword kw">end</span></pre> </div> </div>