|
681 | 681 | </code></pre></div>
|
682 | 682 |
|
683 | 683 | <ul>
|
684 |
| -<li><strong>ISO strings come in following forms: <code class="python hljs"><span class="hljs-string">'YYYY-MM-DD'</span></code>, <code class="python hljs"><span class="hljs-string">'HH:MM:SS.ffffff[±<offset>]'</span></code>, or both separated by a space or a <code class="python hljs"><span class="hljs-string">'T'</span></code>. Offset is formatted as: <code class="python hljs"><span class="hljs-string">'HH:MM'</span></code>.</strong></li> |
| 684 | +<li><strong>ISO strings come in following forms: <code class="python hljs"><span class="hljs-string">'YYYY-MM-DD'</span></code>, <code class="python hljs"><span class="hljs-string">'HH:MM:SS.ffffff[±<offset>]'</span></code>, or both separated by an arbitrary character. Offset is formatted as: <code class="python hljs"><span class="hljs-string">'HH:MM'</span></code>.</strong></li> |
685 | 685 | <li><strong>On Unix systems Epoch is <code class="python hljs"><span class="hljs-string">'1970-01-01 00:00 UTC'</span></code>, <code class="python hljs"><span class="hljs-string">'1970-01-01 01:00 CET'</span></code>, …</strong></li>
|
686 | 686 | </ul>
|
687 | 687 | <div><h3 id="decode">Decode</h3><pre><code class="python language-python hljs"><str> = <D/T/DT>.isoformat(sep=<span class="hljs-string">'T'</span>) <span class="hljs-comment"># Also timespec='auto/hours/minutes/seconds'.</span>
|
|
701 | 701 | <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>
|
702 | 702 | <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>
|
703 | 703 | </ul>
|
704 |
| -<div><h3 id="arithmetics">Arithmetics</h3><pre><code class="python language-python apache hljs"><D/DT> = <D/DT> ± <TD> <span class="hljs-comment"># Result can fall into missing hour.</span> |
705 |
| -<TD> = <D/DT> - <D/DT> <span class="hljs-comment"># Ignores time jumps if they share non tzlocal tz.</span> |
| 704 | +<div><h3 id="arithmetics">Arithmetics</h3><pre><code class="python language-python apache hljs"><D/DT> = <D/DT> ± <TD> <span class="hljs-comment"># Returned datetime can fall into missing hour.</span> |
| 705 | +<TD> = <D/DTn> - <D/DTn> <span class="hljs-comment"># Returns the difference, ignoring time jumps.</span> |
| 706 | +<TD> = <DTa> - <DTa> <span class="hljs-comment"># Ignores time jumps if they share tzinfo object.</span> |
706 | 707 | <TD> = <DT_UTC> - <DT_UTC> <span class="hljs-comment"># Convert DTs to UTC to get the actual delta.</span>
|
707 | 708 | </code></pre></div>
|
708 | 709 |
|
|
1671 | 1672 |
|
1672 | 1673 | <div><h3 id="encode-1">Encode</h3><pre><code class="python language-python hljs"><bytes> = bytes(<coll_of_ints>) <span class="hljs-comment"># Ints must be in range from 0 to 255.</span>
|
1673 | 1674 | <bytes> = bytes(<str>, <span class="hljs-string">'utf-8'</span>) <span class="hljs-comment"># Or: <str>.encode('utf-8')</span>
|
1674 |
| -<bytes> = <int>.to_bytes(n_bytes, byteorder=<span class="hljs-string">'big|little'</span>, signed=<span class="hljs-keyword">False</span>) |
| 1675 | +<bytes> = <int>.to_bytes(n_bytes, byteorder=<span class="hljs-string">'big/little'</span>, signed=<span class="hljs-keyword">False</span>) |
1675 | 1676 | <bytes> = bytes.fromhex(<span class="hljs-string">'<hex>'</span>)
|
1676 | 1677 | </code></pre></div>
|
1677 | 1678 |
|
1678 | 1679 | <div><h3 id="decode-1">Decode</h3><pre><code class="python language-python hljs"><list> = list(<bytes>) <span class="hljs-comment"># Returns ints in range from 0 to 255.</span>
|
1679 | 1680 | <str> = str(<bytes>, <span class="hljs-string">'utf-8'</span>) <span class="hljs-comment"># Or: <bytes>.decode('utf-8')</span>
|
1680 |
| -<int> = int.from_bytes(<bytes>, byteorder=<span class="hljs-string">'big|little'</span>, signed=<span class="hljs-keyword">False</span>) |
| 1681 | +<int> = int.from_bytes(<bytes>, byteorder=<span class="hljs-string">'big/little'</span>, signed=<span class="hljs-keyword">False</span>) |
1681 | 1682 | <span class="hljs-string">'<hex>'</span> = <bytes>.hex()
|
1682 | 1683 | </code></pre></div>
|
1683 | 1684 |
|
|
1752 | 1753 | <bytes> = <bytes>.join(<coll_of_mviews>) <span class="hljs-comment"># Joins mviews using bytes object as sep.</span>
|
1753 | 1754 | <list> = list(<mview>) <span class="hljs-comment"># Returns list of ints or floats.</span>
|
1754 | 1755 | <str> = str(<mview>, <span class="hljs-string">'utf-8'</span>)
|
1755 |
| -<int> = int.from_bytes(<mview>, byteorder=<span class="hljs-string">'big|little'</span>, signed=<span class="hljs-keyword">False</span>) |
| 1756 | +<int> = int.from_bytes(<mview>, byteorder=<span class="hljs-string">'big/little'</span>, signed=<span class="hljs-keyword">False</span>) |
1756 | 1757 | <span class="hljs-string">'<hex>'</span> = <mview>.hex()
|
1757 | 1758 | </code></pre></div>
|
1758 | 1759 |
|
|
0 commit comments