<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>docs/config/lua/wezterm.time/Time/sun_times.md - fork/wezterm @ vtparse-0.7.0</title>
<meta name="description" content="docs/config/lua/wezterm.time/Time/sun_times.md in fork/wezterm at vtparse-0.7.0.">
<meta property="og:title" content="docs/config/lua/wezterm.time/Time/sun_times.md - fork/wezterm @ vtparse-0.7.0">
<meta property="og:description" content="docs/config/lua/wezterm.time/Time/sun_times.md in fork/wezterm at vtparse-0.7.0.">
<meta property="og:type" content="website">
<meta property="og:site_name" content="git.julia.blue">
<link rel="stylesheet" href="/css/style.css?v=62">
<script type="module" src="/js/main.js?v=62"></script>
</head>
<body>
<main data-ref="vtparse-0.7.0" data-tip="3bfe6df191af37bc33fe5fe6de12a40f7067f101">
<noscript>
  <div class="callout">
    <p>
      hey! this is a static git repo viewer. commit diffs, file history,
      older commits and other revisions won't load without javascript.
    </p>
    <p>
      you are still able to view source files on branch/tag tips,
      but the experience is degraded.
    </p>
  </div>
</noscript>
<header class="repo"><div>
<h1>fork/wezterm</h1>
</div>
<pre class="clone">git clone https://git.julia.blue/fork/wezterm</pre>
</header>
<p class="snapshot-commit"><span class="commit-author">Wez Furlong</span><span class="commit-message" data-commit="40081cb5737da32058a3c87e14b84d8f2bfefdc4">docs: update a bunch of since lines to new macro</span><span class="snapshot-sha sha" data-commit="40081cb5737da32058a3c87e14b84d8f2bfefdc4">40081cb57</span><time datetime="2023-03-20T22:01:24-07:00" title="2023-03-20 22:01:24 -0700">2023-03-20</time></p>
<header class="topbar"><details class="switcher"><summary>vtparse-0.7.0</summary><div class="menu"><strong>branches</strong><a href="/fork/wezterm/ref/main/">main</a><strong>tags</strong><a href="/fork/wezterm/ref/termiz-0.23.1/">termiz-0.23.1</a><a href="/fork/wezterm/ref/termiz-0.23.2/">termiz-0.23.2</a><a href="/fork/wezterm/ref/termiz-0.23.3/">termiz-0.23.3</a><a href="/fork/wezterm/ref/termwiz-0.23.0/">termwiz-0.23.0</a><a href="/fork/wezterm/ref/termwiz-0.23.1/">termwiz-0.23.1</a><a href="/fork/wezterm/ref/termwiz-0.23.2/">termwiz-0.23.2</a><a href="/fork/wezterm/ref/termwiz-0.23.3/">termwiz-0.23.3</a><a class="current" href="/fork/wezterm/ref/vtparse-0.7.0/">vtparse-0.7.0</a><a class="all" href="/fork/wezterm/refs">all refs →</a></div></details><nav class="crumbs"><a href="/fork/wezterm/">wezterm</a> / <a href="/fork/wezterm/ref/vtparse-0.7.0/tree/docs/">docs</a> / <a href="/fork/wezterm/ref/vtparse-0.7.0/tree/docs/config/">config</a> / <a href="/fork/wezterm/ref/vtparse-0.7.0/tree/docs/config/lua/">lua</a> / <a href="/fork/wezterm/ref/vtparse-0.7.0/tree/docs/config/lua/wezterm.time/">wezterm.time</a> / <a href="/fork/wezterm/ref/vtparse-0.7.0/tree/docs/config/lua/wezterm.time/Time/">Time</a> / <span class="cur">sun_times.md</span></nav>
<span class="view-stats"><span>1.4 KiB</span><span>41 lines</span></span><span class="actions"><a class="raw" href="/fork/wezterm/raw/d372fccc9cee9816e1a6dc7d4e6317b4735699e9/docs/config/lua/wezterm.time/Time/sun_times.md">raw</a></span></header>
<div class="markdown-view"><input type="radio" name="markdown-view" id="markdown-rendered" checked><label for="markdown-rendered">rendered</label><input type="radio" name="markdown-view" id="markdown-code"><label for="markdown-code">code</label><section class="readme rendered"><h1><code>Time:sun_times(lat, lon)</code></h1>
<p>{{since('20220807-113146-c2fee766')}}</p>
<p>For the date component of the time object, compute the times of the sun rise
and sun set for the given latitude and longitude.</p>
<p>For the time component of the time object, compute whether the sun is currently
up, and the progression of the sun through either the day or night.</p>
<p>Returns that information as a table:</p>
<pre>&gt; wezterm.time.now():sun_times(33.44, -112)
{
    &quot;progression&quot;: 0.41843971631205673,
    &quot;rise&quot;: &quot;Time(utc: 2022-07-17T12:29:42.493449687+00:00)&quot;,
    &quot;set&quot;: &quot;Time(utc: 2022-07-18T02:36:40.776247739+00:00)&quot;,
    &quot;up&quot;: true,
}
</pre>
<p>The example above computes the information for Phoenix, Arizona at the time
this documentation was being written.</p>
<p>The sun is presently up (<code>up == true</code>) and is about 41%
(<code>progression=0.41843971631205673</code>) of its way through the daylight portion of
the day.</p>
<p>If the sun would be down at the time portion of the time object, then <code>up == false</code> and the <code>progression</code> would indicate the proportion of the way through
the night.</p>
<p>This information is potentially useful if you want to vary color scheme or
other configuration based on the time of day.</p>
<p>If the provided latitude and longitude specify a location at one of the poles,
then the day or night may be longer than 24 hours. In that case <code>rise</code> and
<code>set</code> will be <code>nil</code>, <code>progression</code> will be <code>0</code> and <code>up</code> will indicate if it is
polar daytime (<code>up==true</code>) or polar night time (<code>up == false</code>).</p>
</section><div class="code-panel"><pre class="code src language-markdown"><span class="code-line"><a class="ln" id="L1" href="#L1">1</a><span class="code-text"><a-p>#</a-p> <a-tt>`Time:sun_times(lat, lon)`</a-tt></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L2" href="#L2">2</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L3" href="#L3">3</a><span class="code-text">{{since(&#39;20220807-113146-c2fee766&#39;)}}</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L4" href="#L4">4</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L5" href="#L5">5</a><span class="code-text">For the date component of the time object, compute the times of the sun rise</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L6" href="#L6">6</a><span class="code-text">and sun set for the given latitude and longitude.</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L7" href="#L7">7</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L8" href="#L8">8</a><span class="code-text">For the time component of the time object, compute whether the sun is currently</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L9" href="#L9">9</a><span class="code-text">up, and the progression of the sun through either the day or night.</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L10" href="#L10">10</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L11" href="#L11">11</a><span class="code-text">Returns that information as a table:</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L12" href="#L12">12</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L13" href="#L13">13</a><span class="code-text"><a-p>```</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L14" href="#L14">14</a><span class="code-text"><a-p>&gt; wezterm.time.now():sun_times(33.44, -112)</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L15" href="#L15">15</a><span class="code-text"><a-p>{</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L16" href="#L16">16</a><span class="code-text"><a-p>    &quot;progression&quot;: 0.41843971631205673,</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L17" href="#L17">17</a><span class="code-text"><a-p>    &quot;rise&quot;: &quot;Time(utc: 2022-07-17T12:29:42.493449687+00:00)&quot;,</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L18" href="#L18">18</a><span class="code-text"><a-p>    &quot;set&quot;: &quot;Time(utc: 2022-07-18T02:36:40.776247739+00:00)&quot;,</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L19" href="#L19">19</a><span class="code-text"><a-p>    &quot;up&quot;: true,</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L20" href="#L20">20</a><span class="code-text"><a-p>}</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L21" href="#L21">21</a><span class="code-text"><a-p>```</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L22" href="#L22">22</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L23" href="#L23">23</a><span class="code-text">The example above computes the information for Phoenix, Arizona at the time</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L24" href="#L24">24</a><span class="code-text">this documentation was being written.</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L25" href="#L25">25</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L26" href="#L26">26</a><span class="code-text">The sun is presently up (`up == true`) and is about 41%</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L27" href="#L27">27</a><span class="code-text">(`progression=0.41843971631205673`) of its way through the daylight portion of</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L28" href="#L28">28</a><span class="code-text">the day.</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L29" href="#L29">29</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L30" href="#L30">30</a><span class="code-text">If the sun would be down at the time portion of the time object, then `up ==</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L31" href="#L31">31</a><span class="code-text">false` and the `progression` would indicate the proportion of the way through</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L32" href="#L32">32</a><span class="code-text">the night.</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L33" href="#L33">33</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L34" href="#L34">34</a><span class="code-text">This information is potentially useful if you want to vary color scheme or</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L35" href="#L35">35</a><span class="code-text">other configuration based on the time of day.</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L36" href="#L36">36</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L37" href="#L37">37</a><span class="code-text">If the provided latitude and longitude specify a location at one of the poles,</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L38" href="#L38">38</a><span class="code-text">then the day or night may be longer than 24 hours. In that case `rise` and</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L39" href="#L39">39</a><span class="code-text">`set` will be `nil`, `progression` will be `0` and `up` will indicate if it is</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L40" href="#L40">40</a><span class="code-text">polar daytime (`up==true`) or polar night time (`up == false`).</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L41" href="#L41">41</a><span class="code-text"></span></span></pre></div></div>
</main>
</body>
</html>
