|
644 | 644 | <li><strong>Time and datetime can be 'aware' <code class="apache hljs"><span class="hljs-section"><a></span></code>, meaning they have defined timezone, or 'naive' <code class="apache hljs"><span class="hljs-section"><n></span></code>, meaning they don't.</strong></li>
|
645 | 645 | <li><strong>If object is naive it is presumed to be in the system's timezone.</strong></li>
|
646 | 646 | </ul><pre><code class="python language-python hljs"><span class="hljs-keyword">from</span> datetime <span class="hljs-keyword">import</span> date, time, datetime, timedelta
|
647 |
| -<span class="hljs-keyword">from</span> dateutil.tz <span class="hljs-keyword">import</span> UTC, tzlocal, gettz |
| 647 | +<span class="hljs-keyword">from</span> dateutil.tz <span class="hljs-keyword">import</span> UTC, tzlocal, gettz, resolve_imaginary |
648 | 648 | </code></pre></div>
|
649 | 649 |
|
650 | 650 |
|
|
658 | 658 | <ul>
|
659 | 659 | <li><strong>Use <code class="python hljs"><span class="hljs-string">'<D/DT>.weekday()'</span></code> to get the day of the week (Mon == 0).</strong></li>
|
660 | 660 | <li><strong><code class="python hljs"><span class="hljs-string">'fold=1'</span></code> means second pass in case of time jumping back for one hour.</strong></li>
|
| 661 | +<li><strong><code class="apache hljs"><code class="python language-python hljs"><span class="hljs-string">'<DT> = resolve_imaginary(<DT>)'</span></code></code> fixes DTs that fall into missing hour.</strong></li> |
661 | 662 | </ul>
|
662 | 663 | <div><h3 id="now">Now</h3><pre><code class="python language-python hljs"><D/DTn> = D/DT.today() <span class="hljs-comment"># Current local date or naive datetime.</span>
|
663 | 664 | <DTn> = DT.utcnow() <span class="hljs-comment"># Naive datetime from current UTC time.</span>
|
|
701 | 702 |
|
702 | 703 | <ul>
|
703 | 704 | <li><strong>When parsing, <code class="python hljs"><span class="hljs-string">'%z'</span></code> also accepts <code class="python hljs"><span class="hljs-string">'±HH:MM'</span></code>.</strong></li>
|
704 |
| -<li><strong>For abbreviated weekday and month use <code class="python hljs"><span class="hljs-string">'%a'</span></code> and <code class="python hljs"><span class="hljs-string">'%b'</span></code>.</strong></li> |
705 | 705 | </ul>
|
706 |
| -<div><h3 id="arithmetics">Arithmetics</h3><pre><code class="python language-python apache hljs"><TD> = <D/DT> - <D/DT> |
707 |
| -<D/DT> = <D/DT> ± <TD> |
| 706 | +<div><h3 id="arithmetics">Arithmetics</h3><pre><code class="python language-python apache hljs"><TD> = <D/DT> - <D/DT> <span class="hljs-comment"># Returns the difference between wall times.</span> |
| 707 | +<D/DT> = <D/DT> ± <TD> <span class="hljs-comment"># Result can be an imaginary time.</span> |
708 | 708 | <TD> = <TD> ± <TD>
|
709 | 709 | <TD> = <TD> * <real>
|
710 | 710 | </code></pre></div>
|
|
0 commit comments