docs/Lazier/TimeZone.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>
Module: Lazier::TimeZone
— Documentation by YARD 0.9.5
</title>
<link rel="stylesheet" href="../css/style.css" type="text/css" charset="utf-8" />
<link rel="stylesheet" href="../css/common.css" type="text/css" charset="utf-8" />
<script type="text/javascript" charset="utf-8">
pathId = "Lazier::TimeZone";
relpath = '../';
</script>
<script type="text/javascript" charset="utf-8" src="../js/jquery.js"></script>
<script type="text/javascript" charset="utf-8" src="../js/app.js"></script>
</head>
<body>
<div class="nav_wrap">
<iframe id="nav" src="../class_list.html"></iframe>
<div id="resizer"></div>
</div>
<div id="main" tabindex="-1">
<div id="header">
<div id="menu">
<a href="../_index.html">Index (T)</a> »
<span class='title'><span class='object_link'><a href="../Lazier.html" title="Lazier (module)">Lazier</a></span></span>
»
<span class="title">TimeZone</span>
</div>
<div id="search">
<a class="full_list_link" id="class_list_link"
href="../class_list.html">
<svg width="24" height="24">
<rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
<rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
<rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
</svg>
</a>
</div>
<div class="clear"></div>
</div>
<iframe id="search_frame" src="../class_list.html"></iframe>
<div id="content"><h1>Module: Lazier::TimeZone
</h1>
<div class="box_info">
<dl>
<dt>Extended by:</dt>
<dd>ActiveSupport::Concern</dd>
</dl>
<dl>
<dt>Defined in:</dt>
<dd>lib/lazier/timezone.rb</dd>
</dl>
</div>
<h2>Overview</h2><div class="docstring">
<div class="discussion">
<p>Extensions for <code>TimeZone</code> objects.</p>
</div>
</div>
<div class="tags">
</div><h2>Defined Under Namespace</h2>
<p class="children">
<strong class="modules">Modules:</strong> <span class='object_link'><a href="TimeZone/ClassMethods.html" title="Lazier::TimeZone::ClassMethods (module)">ClassMethods</a></span>
</p>
<h2>Constant Summary</h2>
<dl class="constants">
<dt id="ALREADY_PARAMETERIZED-constant" class="">ALREADY_PARAMETERIZED =
<div class="docstring">
<div class="discussion">
<p>Pattern for a parameterized timezone.</p>
</div>
</div>
<div class="tags">
</div>
</dt>
<dd><pre class="code"><span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>^[+-]\d{4}@[a-z-]+</span><span class='regexp_end'>/</span></span></pre></dd>
<dt id="PARAMETERIZER-constant" class="">PARAMETERIZER =
<div class="docstring">
<div class="discussion">
<p>Pattern for a unparameterized timezone.</p>
</div>
</div>
<div class="tags">
</div>
</dt>
<dd><pre class="code"><span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>^(
\(
[a-z]+ # UTC Label
(?<offset>([+-])(\d{2})(:?)(\d{2}))
\)
\s(?<label>.+)
)$</span><span class='regexp_end'>/xi</span></span></pre></dd>
</dl>
<h2>
Instance Method Summary
<small><a href="#" class="summary_toggle">collapse</a></small>
</h2>
<ul class="summary">
<li class="public ">
<span class="summary_signature">
<a href="#aliases-instance_method" title="#aliases (instance method)">#<strong>aliases</strong> ⇒ Array </a>
</span>
<span class="summary_desc"><div class='inline'><p>Returns a list of valid aliases (city names) for this timezone (basing on the offset).</p>
</div></span>
</li>
<li class="public ">
<span class="summary_signature">
<a href="#current_alias-instance_method" title="#current_alias (instance method)">#<strong>current_alias</strong> ⇒ String </a>
</span>
<span class="summary_desc"><div class='inline'><p>Returns the current alias for this timezone.</p>
</div></span>
</li>
<li class="public ">
<span class="summary_signature">
<a href="#current_alias%3D-instance_method" title="#current_alias= (instance method)">#<strong>current_alias=</strong>(new_alias) ⇒ Object </a>
</span>
<span class="summary_desc"><div class='inline'><p>Sets the current alias.</p>
</div></span>
</li>
<li class="public ">
<span class="summary_signature">
<a href="#current_name-instance_method" title="#current_name (instance method)">#<strong>current_name</strong>(dst = false, dst_label: " (DST)", year: nil) ⇒ String </a>
</span>
<span class="summary_desc"><div class='inline'><p>Returns the current name.</p>
</div></span>
</li>
<li class="public ">
<span class="summary_signature">
<a href="#current_offset-instance_method" title="#current_offset (instance method)">#<strong>current_offset</strong>(rational = false, date = nil) ⇒ Fixnum|Rational </a>
</span>
<span class="summary_desc"><div class='inline'><p>Returns the current offset for this timezone, taking care of Daylight Saving Time (DST).</p>
</div></span>
</li>
<li class="public ">
<span class="summary_signature">
<a href="#dst_correction-instance_method" title="#dst_correction (instance method)">#<strong>dst_correction</strong>(rational = false, year = nil) ⇒ Fixnum|Rational </a>
</span>
<span class="summary_desc"><div class='inline'><p>Return the correction applied to the standard offset the timezone when the Daylight Saving Time (DST) is active.</p>
</div></span>
</li>
<li class="public ">
<span class="summary_signature">
<a href="#dst_period-instance_method" title="#dst_period (instance method)">#<strong>dst_period</strong>(year = nil) ⇒ TimezonePeriod </a>
</span>
<span class="summary_desc"><div class='inline'><p>Gets a period for this timezone when the Daylight Saving Time (DST) is active (it takes care of different hemispheres).</p>
</div></span>
</li>
<li class="public ">
<span class="summary_signature">
<a href="#offset-instance_method" title="#offset (instance method)">#<strong>offset</strong>(rational: false, dst: false, year: nil) ⇒ Fixnum|Rational </a>
</span>
<span class="summary_desc"><div class='inline'><p>Returns the standard offset for this timezone.</p>
</div></span>
</li>
<li class="public ">
<span class="summary_signature">
<a href="#to_str-instance_method" title="#to_str (instance method)">#<strong>to_str</strong>(dst = false, **args) ⇒ String </a>
</span>
<span class="summary_desc"><div class='inline'><p>Formats this zone as a string.</p>
</div></span>
</li>
<li class="public ">
<span class="summary_signature">
<a href="#uses_dst%3F-instance_method" title="#uses_dst? (instance method)">#<strong>uses_dst?</strong>(reference = nil) ⇒ Boolean </a>
</span>
<span class="summary_desc"><div class='inline'><p>Checks if the timezone uses Daylight Saving Time (DST) for that date or year.</p>
</div></span>
</li>
</ul>
<div id="instance_method_details" class="method_details_list">
<h2>Instance Method Details</h2>
<div class="method_details first">
<h3 class="signature first" id="aliases-instance_method">
#<strong>aliases</strong> ⇒ <tt>Array</tt>
</h3><div class="docstring">
<div class="discussion">
<p>Returns a list of valid aliases (city names) for this timezone (basing on the offset).</p>
</div>
</div>
<div class="tags">
<p class="tag_title">Returns:</p>
<ul class="return">
<li>
<span class='type'>(<tt>Array</tt>)</span>
—
<div class='inline'><p>A list of aliases for this timezone</p>
</div>
</li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
154
155
156
157</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/lazier/timezone.rb', line 154</span>
<span class='kw'>def</span> <span class='id identifier rubyid_aliases'>aliases</span>
<span class='id identifier rubyid_reference'>reference</span> <span class='op'>=</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_class'>class</span><span class='op'>::</span><span class='const'>MAPPING</span><span class='period'>.</span><span class='id identifier rubyid_fetch'>fetch</span><span class='lparen'>(</span><span class='id identifier rubyid_name'>name</span><span class='comma'>,</span> <span class='id identifier rubyid_name'>name</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_gsub'>gsub</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>_</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'> </span><span class='tstring_end'>"</span></span><span class='rparen'>)</span>
<span class='ivar'>@aliases</span> <span class='op'>||=</span> <span class='lparen'>(</span><span class='lbracket'>[</span><span class='id identifier rubyid_reference'>reference</span><span class='rbracket'>]</span> <span class='op'>+</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_class'>class</span><span class='op'>::</span><span class='const'>MAPPING</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_name'>name</span><span class='comma'>,</span> <span class='id identifier rubyid_zone'>zone</span><span class='op'>|</span> <span class='id identifier rubyid_format_alias'>format_alias</span><span class='lparen'>(</span><span class='id identifier rubyid_name'>name</span><span class='comma'>,</span> <span class='id identifier rubyid_zone'>zone</span><span class='comma'>,</span> <span class='id identifier rubyid_reference'>reference</span><span class='rparen'>)</span> <span class='rbrace'>}</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_uniq'>uniq</span><span class='period'>.</span><span class='id identifier rubyid_compact'>compact</span><span class='period'>.</span><span class='id identifier rubyid_sort'>sort</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
<div class="method_details ">
<h3 class="signature " id="current_alias-instance_method">
#<strong>current_alias</strong> ⇒ <tt><span class='object_link'><a href="String.html" title="Lazier::String (module)">String</a></span></tt>
</h3><div class="docstring">
<div class="discussion">
<p>Returns the current alias for this timezone.</p>
</div>
</div>
<div class="tags">
<p class="tag_title">Returns:</p>
<ul class="return">
<li>
<span class='type'>(<tt><span class='object_link'><a href="String.html" title="Lazier::String (module)">String</a></span></tt>)</span>
—
<div class='inline'><p>The current alias or the first alias of the current timezone.</p>
</div>
</li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
172
173
174
175
176
177
178
179</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/lazier/timezone.rb', line 172</span>
<span class='kw'>def</span> <span class='id identifier rubyid_current_alias'>current_alias</span>
<span class='kw'>if</span> <span class='ivar'>@current_alias</span>
<span class='ivar'>@current_alias</span>
<span class='kw'>else</span>
<span class='id identifier rubyid_identifier'>identifier</span> <span class='op'>=</span> <span class='id identifier rubyid_name'>name</span>
<span class='id identifier rubyid_aliases'>aliases</span><span class='period'>.</span><span class='id identifier rubyid_find'>find</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_a'>a</span><span class='op'>|</span> <span class='id identifier rubyid_a'>a</span> <span class='op'>==</span> <span class='id identifier rubyid_identifier'>identifier</span> <span class='rbrace'>}</span> <span class='op'>||</span> <span class='id identifier rubyid_aliases'>aliases</span><span class='period'>.</span><span class='id identifier rubyid_first'>first</span>
<span class='kw'>end</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
<div class="method_details ">
<h3 class="signature " id="current_alias=-instance_method">
#<strong>current_alias=</strong>(new_alias) ⇒ <tt><span class='object_link'><a href="Object.html" title="Lazier::Object (module)">Object</a></span></tt>
</h3><div class="docstring">
<div class="discussion">
<p>Sets the current alias.</p>
</div>
</div>
<div class="tags">
<p class="tag_title">Parameters:</p>
<ul class="param">
<li>
<span class='name'>new_alias</span>
<span class='type'>(<tt><span class='object_link'><a href="String.html" title="Lazier::String (module)">String</a></span></tt>)</span>
—
<div class='inline'><p>The new current alias.</p>
</div>
</li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
184
185
186</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/lazier/timezone.rb', line 184</span>
<span class='kw'>def</span> <span class='id identifier rubyid_current_alias='>current_alias=</span><span class='lparen'>(</span><span class='id identifier rubyid_new_alias'>new_alias</span><span class='rparen'>)</span>
<span class='ivar'>@current_alias</span> <span class='op'>=</span> <span class='id identifier rubyid_new_alias'>new_alias</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
<div class="method_details ">
<h3 class="signature " id="current_name-instance_method">
#<strong>current_name</strong>(dst = false, dst_label: " (DST)", year: nil) ⇒ <tt><span class='object_link'><a href="String.html" title="Lazier::String (module)">String</a></span></tt>
</h3><div class="docstring">
<div class="discussion">
<p>Returns the current name.</p>
</div>
</div>
<div class="tags">
<p class="tag_title">Parameters:</p>
<ul class="param">
<li>
<span class='name'>dst</span>
<span class='type'>(<tt><span class='object_link'><a href="Boolean.html" title="Lazier::Boolean (module)">Boolean</a></span></tt>)</span>
<em class="default">(defaults to: <tt>false</tt>)</em>
—
<div class='inline'><p>Whether to return the name with DST indication.</p>
</div>
</li>
<li>
<span class='name'>dst_label</span>
<span class='type'>(<tt><span class='object_link'><a href="String.html" title="Lazier::String (module)">String</a></span></tt>)</span>
—
<div class='inline'><p>Label for the DST indication. Defaults to ` (DST)`.</p>
</div>
</li>
<li>
<span class='name'>year</span>
<span class='type'>(<tt>Fixnum</tt>)</span>
—
<div class='inline'><p>The year to which refer to. Defaults to the current year. <em>Only required when <code>dst</code> is true</em>.</p>
</div>
</li>
</ul>
<p class="tag_title">Returns:</p>
<ul class="return">
<li>
<span class='type'>(<tt><span class='object_link'><a href="String.html" title="Lazier::String (module)">String</a></span></tt>)</span>
—
<div class='inline'><p>The name for the zone.</p>
</div>
</li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
194
195
196
197
198
199</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/lazier/timezone.rb', line 194</span>
<span class='kw'>def</span> <span class='id identifier rubyid_current_name'>current_name</span><span class='lparen'>(</span><span class='id identifier rubyid_dst'>dst</span> <span class='op'>=</span> <span class='kw'>false</span><span class='comma'>,</span> <span class='label'>dst_label:</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'> (DST)</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='label'>year:</span> <span class='kw'>nil</span><span class='rparen'>)</span>
<span class='id identifier rubyid_year'>year</span> <span class='op'>||=</span> <span class='const'>Date</span><span class='period'>.</span><span class='id identifier rubyid_current'>current</span><span class='period'>.</span><span class='id identifier rubyid_year'>year</span>
<span class='id identifier rubyid_rv'>rv</span> <span class='op'>=</span> <span class='id identifier rubyid_current_alias'>current_alias</span>
<span class='id identifier rubyid_rv'>rv</span> <span class='op'>+=</span> <span class='id identifier rubyid_dst_label'>dst_label</span> <span class='kw'>if</span> <span class='id identifier rubyid_dst'>dst</span> <span class='op'>&&</span> <span class='id identifier rubyid_uses_dst?'>uses_dst?</span><span class='lparen'>(</span><span class='id identifier rubyid_year'>year</span><span class='rparen'>)</span>
<span class='id identifier rubyid_rv'>rv</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
<div class="method_details ">
<h3 class="signature " id="current_offset-instance_method">
#<strong>current_offset</strong>(rational = false, date = nil) ⇒ <tt>Fixnum|Rational</tt>
</h3><div class="docstring">
<div class="discussion">
<p>Returns the current offset for this timezone, taking care of Daylight Saving Time (DST).</p>
</div>
</div>
<div class="tags">
<p class="tag_title">Parameters:</p>
<ul class="param">
<li>
<span class='name'>rational</span>
<span class='type'>(<tt><span class='object_link'><a href="Boolean.html" title="Lazier::Boolean (module)">Boolean</a></span></tt>)</span>
<em class="default">(defaults to: <tt>false</tt>)</em>
—
<div class='inline'><p>Whether to return the offset as a Rational.</p>
</div>
</li>
<li>
<span class='name'>date</span>
<span class='type'>(<tt><span class='object_link'><a href="DateTime.html" title="Lazier::DateTime (module)">DateTime</a></span>|NilClass</tt>)</span>
<em class="default">(defaults to: <tt>nil</tt>)</em>
—
<div class='inline'><p>The date to consider. Defaults to now.</p>
</div>
</li>
</ul>
<p class="tag_title">Returns:</p>
<ul class="return">
<li>
<span class='type'>(<tt>Fixnum|Rational</tt>)</span>
—
<div class='inline'><p>The offset of this timezone.</p>
</div>
</li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
164
165
166
167</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/lazier/timezone.rb', line 164</span>
<span class='kw'>def</span> <span class='id identifier rubyid_current_offset'>current_offset</span><span class='lparen'>(</span><span class='id identifier rubyid_rational'>rational</span> <span class='op'>=</span> <span class='kw'>false</span><span class='comma'>,</span> <span class='id identifier rubyid_date'>date</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='rparen'>)</span>
<span class='id identifier rubyid_date'>date</span> <span class='op'>=</span> <span class='lparen'>(</span><span class='id identifier rubyid_date'>date</span> <span class='op'>||</span> <span class='op'>::</span><span class='const'>DateTime</span><span class='period'>.</span><span class='id identifier rubyid_current'>current</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_in_time_zone'>in_time_zone</span>
<span class='id identifier rubyid_offset'>offset</span><span class='lparen'>(</span><span class='label'>rational:</span> <span class='id identifier rubyid_rational'>rational</span><span class='comma'>,</span> <span class='label'>dst:</span> <span class='id identifier rubyid_date'>date</span><span class='period'>.</span><span class='id identifier rubyid_dst?'>dst?</span><span class='comma'>,</span> <span class='label'>year:</span> <span class='id identifier rubyid_date'>date</span><span class='period'>.</span><span class='id identifier rubyid_year'>year</span><span class='rparen'>)</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
<div class="method_details ">
<h3 class="signature " id="dst_correction-instance_method">
#<strong>dst_correction</strong>(rational = false, year = nil) ⇒ <tt>Fixnum|Rational</tt>
</h3><div class="docstring">
<div class="discussion">
<p>Return the correction applied to the standard offset the timezone when the Daylight Saving Time (DST) is active.</p>
</div>
</div>
<div class="tags">
<p class="tag_title">Parameters:</p>
<ul class="param">
<li>
<span class='name'>rational</span>
<span class='type'>(<tt><span class='object_link'><a href="Boolean.html" title="Lazier::Boolean (module)">Boolean</a></span></tt>)</span>
<em class="default">(defaults to: <tt>false</tt>)</em>
—
<div class='inline'><p>Whether to return the offset as a Rational.</p>
</div>
</li>
<li>
<span class='name'>year</span>
<span class='type'>(<tt>Fixnum|NilClass</tt>)</span>
<em class="default">(defaults to: <tt>nil</tt>)</em>
—
<div class='inline'><p>The year to which refer to. Defaults to the current year.</p>
</div>
</li>
</ul>
<p class="tag_title">Returns:</p>
<ul class="return">
<li>
<span class='type'>(<tt>Fixnum|Rational</tt>)</span>
—
<div class='inline'><p>The correction for dst.</p>
</div>
</li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
250
251
252
253</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/lazier/timezone.rb', line 250</span>
<span class='kw'>def</span> <span class='id identifier rubyid_dst_correction'>dst_correction</span><span class='lparen'>(</span><span class='id identifier rubyid_rational'>rational</span> <span class='op'>=</span> <span class='kw'>false</span><span class='comma'>,</span> <span class='id identifier rubyid_year'>year</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='rparen'>)</span>
<span class='id identifier rubyid_rv'>rv</span> <span class='op'>=</span> <span class='id identifier rubyid_dst_offset'>dst_offset</span><span class='lparen'>(</span><span class='id identifier rubyid_year'>year</span><span class='comma'>,</span> <span class='symbol'>:std_offset</span><span class='rparen'>)</span>
<span class='id identifier rubyid_rational'>rational</span> <span class='op'>?</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_class'>class</span><span class='period'>.</span><span class='id identifier rubyid_rationalize_offset'>rationalize_offset</span><span class='lparen'>(</span><span class='id identifier rubyid_rv'>rv</span><span class='rparen'>)</span> <span class='op'>:</span> <span class='id identifier rubyid_rv'>rv</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
<div class="method_details ">
<h3 class="signature " id="dst_period-instance_method">
#<strong>dst_period</strong>(year = nil) ⇒ <tt>TimezonePeriod</tt>
</h3><div class="docstring">
<div class="discussion">
<p>Gets a period for this timezone when the Daylight Saving Time (DST) is active (it takes care of different hemispheres).</p>
</div>
</div>
<div class="tags">
<p class="tag_title">Parameters:</p>
<ul class="param">
<li>
<span class='name'>year</span>
<span class='type'>(<tt>Fixnum|NilClass</tt>)</span>
<em class="default">(defaults to: <tt>nil</tt>)</em>
—
<div class='inline'><p>The year to which refer to. Defaults to the current year.</p>
</div>
</li>
</ul>
<p class="tag_title">Returns:</p>
<ul class="return">
<li>
<span class='type'>(<tt>TimezonePeriod</tt>)</span>
—
<div class='inline'><p>A period when the Daylight Saving Time (DST) is active or <code>nil</code> if the timezone doesn’t use DST for that year.</p>
</div>
</li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
235
236
237
238
239
240
241
242
243</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/lazier/timezone.rb', line 235</span>
<span class='kw'>def</span> <span class='id identifier rubyid_dst_period'>dst_period</span><span class='lparen'>(</span><span class='id identifier rubyid_year'>year</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='rparen'>)</span>
<span class='id identifier rubyid_year'>year</span> <span class='op'>||=</span> <span class='op'>::</span><span class='const'>Date</span><span class='period'>.</span><span class='id identifier rubyid_current'>current</span><span class='period'>.</span><span class='id identifier rubyid_year'>year</span>
<span class='id identifier rubyid_period'>period</span> <span class='op'>=</span> <span class='id identifier rubyid_period_for_utc'>period_for_utc</span><span class='lparen'>(</span><span class='op'>::</span><span class='const'>DateTime</span><span class='period'>.</span><span class='id identifier rubyid_civil'>civil</span><span class='lparen'>(</span><span class='id identifier rubyid_year'>year</span><span class='comma'>,</span> <span class='int'>7</span><span class='comma'>,</span> <span class='int'>15</span><span class='comma'>,</span> <span class='int'>12</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_utc'>utc</span><span class='rparen'>)</span> <span class='comment'># Summer for the northern hemisphere
</span> <span class='id identifier rubyid_period'>period</span> <span class='op'>=</span> <span class='id identifier rubyid_period_for_utc'>period_for_utc</span><span class='lparen'>(</span><span class='op'>::</span><span class='const'>DateTime</span><span class='period'>.</span><span class='id identifier rubyid_civil'>civil</span><span class='lparen'>(</span><span class='id identifier rubyid_year'>year</span><span class='comma'>,</span> <span class='int'>1</span><span class='comma'>,</span> <span class='int'>15</span><span class='comma'>,</span> <span class='int'>12</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_utc'>utc</span><span class='rparen'>)</span> <span class='kw'>unless</span> <span class='id identifier rubyid_period'>period</span><span class='period'>.</span><span class='id identifier rubyid_dst?'>dst?</span> <span class='comment'># Summer for the southern hemisphere
</span> <span class='id identifier rubyid_period'>period</span><span class='period'>.</span><span class='id identifier rubyid_dst?'>dst?</span> <span class='op'>?</span> <span class='id identifier rubyid_period'>period</span> <span class='op'>:</span> <span class='kw'>nil</span>
<span class='kw'>rescue</span>
<span class='kw'>nil</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
<div class="method_details ">
<h3 class="signature " id="offset-instance_method">
#<strong>offset</strong>(rational: false, dst: false, year: nil) ⇒ <tt>Fixnum|Rational</tt>
</h3><div class="docstring">
<div class="discussion">
<p>Returns the standard offset for this timezone.</p>
</div>
</div>
<div class="tags">
<p class="tag_title">Parameters:</p>
<ul class="param">
<li>
<span class='name'>rational</span>
<span class='type'>(<tt><span class='object_link'><a href="Boolean.html" title="Lazier::Boolean (module)">Boolean</a></span></tt>)</span>
—
<div class='inline'><p>Whether to return he offset as a <code>Rational</code>.</p>
</div>
</li>
<li>
<span class='name'>dst</span>
<span class='type'>(<tt><span class='object_link'><a href="Boolean.html" title="Lazier::Boolean (module)">Boolean</a></span></tt>)</span>
—
<div class='inline'><p>Whether to return the offset when the DST is active.</p>
</div>
</li>
<li>
<span class='name'>year</span>
<span class='type'>(<tt>Fixnum|NilClass</tt>)</span>
—
<div class='inline'><p>The year to which refer to. Defaults to the current year.</p>
</div>
</li>
</ul>
<p class="tag_title">Returns:</p>
<ul class="return">
<li>
<span class='type'>(<tt>Fixnum|Rational</tt>)</span>
—
<div class='inline'><p>The offset of this timezone.</p>
</div>
</li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
207
208
209
210
211
212
213
214
215
216
217</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/lazier/timezone.rb', line 207</span>
<span class='kw'>def</span> <span class='id identifier rubyid_offset'>offset</span><span class='lparen'>(</span><span class='label'>rational:</span> <span class='kw'>false</span><span class='comma'>,</span> <span class='label'>dst:</span> <span class='kw'>false</span><span class='comma'>,</span> <span class='label'>year:</span> <span class='kw'>nil</span><span class='rparen'>)</span>
<span class='id identifier rubyid_rv'>rv</span> <span class='op'>=</span>
<span class='kw'>if</span> <span class='id identifier rubyid_dst'>dst</span>
<span class='id identifier rubyid_period'>period</span> <span class='op'>=</span> <span class='id identifier rubyid_dst_period'>dst_period</span><span class='lparen'>(</span><span class='id identifier rubyid_year'>year</span><span class='rparen'>)</span>
<span class='id identifier rubyid_period'>period</span> <span class='op'>?</span> <span class='id identifier rubyid_period'>period</span><span class='period'>.</span><span class='id identifier rubyid_utc_total_offset'>utc_total_offset</span> <span class='op'>:</span> <span class='int'>0</span>
<span class='kw'>else</span>
<span class='id identifier rubyid_utc_offset'>utc_offset</span>
<span class='kw'>end</span>
<span class='id identifier rubyid_rational'>rational</span> <span class='op'>?</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_class'>class</span><span class='period'>.</span><span class='id identifier rubyid_rationalize_offset'>rationalize_offset</span><span class='lparen'>(</span><span class='id identifier rubyid_rv'>rv</span><span class='rparen'>)</span> <span class='op'>:</span> <span class='id identifier rubyid_rv'>rv</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
<div class="method_details ">
<h3 class="signature " id="to_str-instance_method">
#<strong>to_str</strong>(dst = false, **args) ⇒ <tt><span class='object_link'><a href="String.html" title="Lazier::String (module)">String</a></span></tt>
</h3><div class="docstring">
<div class="discussion">
<p>Formats this zone as a string.</p>
</div>
</div>
<div class="tags">
<p class="tag_title">Parameters:</p>
<ul class="param">
<li>
<span class='name'>dst</span>
<span class='type'>(<tt><span class='object_link'><a href="Boolean.html" title="Lazier::Boolean (module)">Boolean</a></span></tt>)</span>
<em class="default">(defaults to: <tt>false</tt>)</em>
—
<div class='inline'><p>Whether to represent with (DST) active.</p>
</div>
</li>
<li>
<span class='name'>args</span>
<span class='type'>(<tt><span class='object_link'><a href="Hash.html" title="Lazier::Hash (module)">Hash</a></span></tt>)</span>
—
<div class='inline'><p>Parameters for the formatting:</p>
</div>
</li>
</ul>
<p class="tag_title">Options Hash (<tt>**args</tt>):</p>
<ul class="option">
<li>
<span class="name">label</span>
<span class="type">(<tt><span class='object_link'><a href="String.html" title="Lazier::String (module)">String</a></span></tt>)</span>
<span class="default">
</span>
— <div class='inline'><p>: The label to use. Default to the current alias.</p>
</div>
</li>
<li>
<span class="name">dst_label</span>
<span class="type">(<tt><span class='object_link'><a href="String.html" title="Lazier::String (module)">String</a></span></tt>)</span>
<span class="default">
</span>
— <div class='inline'><p>: Label for the DST indication. Defaults to ` (DST)`.</p>
</div>
</li>
<li>
<span class="name">utc_label</span>
<span class="type">(<tt><span class='object_link'><a href="String.html" title="Lazier::String (module)">String</a></span></tt>)</span>
<span class="default">
</span>
— <div class='inline'><p>: Label for the UTC name. Defaults to <code>GMT</code>. *Only used when <code>parameterized</code> is <code>false</code>.</p>
</div>
</li>
<li>
<span class="name">year</span>
<span class="type">(<tt>Fixnum</tt>)</span>
<span class="default">
</span>
— <div class='inline'><p>: The year to which refer to. Defaults to the current year.</p>
</div>
</li>
<li>
<span class="name">parameterized</span>
<span class="type">(<tt><span class='object_link'><a href="Boolean.html" title="Lazier::Boolean (module)">Boolean</a></span></tt>)</span>
<span class="default">
</span>
— <div class='inline'><p>: Whether to represent as parameterized.</p>
</div>
</li>
<li>
<span class="name">with_offset</span>
<span class="type">(<tt><span class='object_link'><a href="Boolean.html" title="Lazier::Boolean (module)">Boolean</a></span></tt>)</span>
<span class="default">
</span>
— <div class='inline'><p>: Whether to include offset into the representation. *Only used when <code>parameterized</code> is <code>true</code>.</p>
</div>
</li>
<li>
<span class="name">offset_position</span>
<span class="type">(<tt>Symbol</tt>)</span>
<span class="default">
</span>
— <div class='inline'><p>: Where to put the offset. Valid values are <code>:begin</code> or <code>:end</code>. *Only used when <code>parameterized</code> is <code>false</code>.</p>
</div>
</li>
<li>
<span class="name">colon</span>
<span class="type">(<tt><span class='object_link'><a href="Boolean.html" title="Lazier::Boolean (module)">Boolean</a></span></tt>)</span>
<span class="default">
</span>
— <div class='inline'><p>: If include a colon in the offset. *Only used when <code>parameterized</code> is <code>false</code>.</p>
</div>
</li>
</ul>
<p class="tag_title">Returns:</p>
<ul class="return">
<li>
<span class='type'>(<tt><span class='object_link'><a href="String.html" title="Lazier::String (module)">String</a></span></tt>)</span>
—
<div class='inline'><p>The string representation for this zone.</p>
</div>
</li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
268
269
270
271
272
273
274
275
276
277
278</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/lazier/timezone.rb', line 268</span>
<span class='kw'>def</span> <span class='id identifier rubyid_to_str'>to_str</span><span class='lparen'>(</span><span class='id identifier rubyid_dst'>dst</span> <span class='op'>=</span> <span class='kw'>false</span><span class='comma'>,</span> <span class='op'>**</span><span class='id identifier rubyid_args'>args</span><span class='rparen'>)</span>
<span class='comment'># PI: Ignore reek on this.
</span> <span class='id identifier rubyid_label'>label</span><span class='comma'>,</span> <span class='id identifier rubyid_dst_label'>dst_label</span><span class='comma'>,</span> <span class='id identifier rubyid_utc_label'>utc_label</span><span class='comma'>,</span> <span class='id identifier rubyid_year'>year</span><span class='comma'>,</span> <span class='id identifier rubyid_parameterized'>parameterized</span><span class='comma'>,</span> <span class='id identifier rubyid_with_offset'>with_offset</span><span class='comma'>,</span> <span class='id identifier rubyid_colon'>colon</span><span class='comma'>,</span> <span class='id identifier rubyid_offset_position'>offset_position</span> <span class='op'>=</span> <span class='id identifier rubyid_prepare_to_str_arguments'>prepare_to_str_arguments</span><span class='lparen'>(</span><span class='id identifier rubyid_args'>args</span><span class='rparen'>)</span>
<span class='kw'>if</span> <span class='id identifier rubyid_parameterized'>parameterized</span>
<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_class'>class</span><span class='period'>.</span><span class='id identifier rubyid_parameterize'>parameterize</span><span class='lparen'>(</span><span class='id identifier rubyid_to_str'>to_str</span><span class='lparen'>(</span><span class='id identifier rubyid_dst'>dst</span><span class='comma'>,</span> <span class='label'>label:</span> <span class='id identifier rubyid_label'>label</span><span class='comma'>,</span> <span class='label'>dst_label:</span> <span class='id identifier rubyid_dst_label'>dst_label</span><span class='comma'>,</span> <span class='label'>utc_label:</span> <span class='id identifier rubyid_utc_label'>utc_label</span><span class='comma'>,</span> <span class='label'>year:</span> <span class='id identifier rubyid_year'>year</span><span class='comma'>,</span> <span class='label'>parameterized:</span> <span class='kw'>false</span><span class='rparen'>)</span><span class='comma'>,</span> <span class='id identifier rubyid_with_offset'>with_offset</span><span class='rparen'>)</span>
<span class='kw'>else</span>
<span class='id identifier rubyid_offset_label'>offset_label</span> <span class='op'>=</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_class'>class</span><span class='period'>.</span><span class='id identifier rubyid_seconds_to_utc_offset'>seconds_to_utc_offset</span><span class='lparen'>(</span><span class='id identifier rubyid_offset'>offset</span><span class='lparen'>(</span><span class='label'>rational:</span> <span class='kw'>false</span><span class='comma'>,</span> <span class='label'>dst:</span> <span class='id identifier rubyid_dst'>dst</span><span class='comma'>,</span> <span class='label'>year:</span> <span class='id identifier rubyid_year'>year</span><span class='rparen'>)</span><span class='comma'>,</span> <span class='id identifier rubyid_colon'>colon</span><span class='rparen'>)</span>
<span class='id identifier rubyid_to_str_unparameterized'>to_str_unparameterized</span><span class='lparen'>(</span><span class='id identifier rubyid_dst'>dst</span> <span class='op'>?</span> <span class='id identifier rubyid_dst_label'>dst_label</span> <span class='op'>:</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='id identifier rubyid_label'>label</span><span class='comma'>,</span> <span class='id identifier rubyid_offset_label'>offset_label</span><span class='comma'>,</span> <span class='id identifier rubyid_offset_position'>offset_position</span><span class='comma'>,</span> <span class='id identifier rubyid_utc_label'>utc_label</span><span class='comma'>,</span> <span class='id identifier rubyid_with_offset'>with_offset</span><span class='rparen'>)</span>
<span class='kw'>end</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
<div class="method_details ">
<h3 class="signature " id="uses_dst?-instance_method">
#<strong>uses_dst?</strong>(reference = nil) ⇒ <tt><span class='object_link'><a href="Boolean.html" title="Lazier::Boolean (module)">Boolean</a></span></tt>
</h3><div class="docstring">
<div class="discussion">
<p>Checks if the timezone uses Daylight Saving Time (DST) for that date or year.</p>
</div>
</div>
<div class="tags">
<p class="tag_title">Parameters:</p>
<ul class="param">
<li>
<span class='name'>reference</span>
<span class='type'>(<tt>Date|<span class='object_link'><a href="DateTime.html" title="Lazier::DateTime (module)">DateTime</a></span>|NilClass</tt>)</span>
<em class="default">(defaults to: <tt>nil</tt>)</em>
—
<div class='inline'><p>The date or year to check. Defaults to the current year.</p>
</div>
</li>
</ul>
<p class="tag_title">Returns:</p>
<ul class="return">
<li>
<span class='type'>(<tt><span class='object_link'><a href="Boolean.html" title="Lazier::Boolean (module)">Boolean</a></span></tt>)</span>
—
<div class='inline'><p><code>true</code> if the zone uses DST for that date or year, <code>false</code> otherwise.</p>
</div>
</li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
223
224
225
226
227
228
229</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/lazier/timezone.rb', line 223</span>
<span class='kw'>def</span> <span class='id identifier rubyid_uses_dst?'>uses_dst?</span><span class='lparen'>(</span><span class='id identifier rubyid_reference'>reference</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='rparen'>)</span>
<span class='kw'>if</span> <span class='id identifier rubyid_reference'>reference</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>Date</span><span class='rparen'>)</span> <span class='op'>||</span> <span class='id identifier rubyid_reference'>reference</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>DateTime</span><span class='rparen'>)</span> <span class='op'>||</span> <span class='id identifier rubyid_reference'>reference</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>Time</span><span class='rparen'>)</span>
<span class='id identifier rubyid_period_for_utc'>period_for_utc</span><span class='lparen'>(</span><span class='id identifier rubyid_reference'>reference</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_dst?'>dst?</span>
<span class='kw'>else</span>
<span class='id identifier rubyid_dst_period'>dst_period</span><span class='lparen'>(</span><span class='id identifier rubyid_reference'>reference</span><span class='rparen'>)</span>
<span class='kw'>end</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
</div>
</div>
<div id="footer">
Generated on Thu Nov 10 11:39:24 2016 by
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
0.9.5 (ruby-2.3.0).
</div>
</div>
</body>
</html>