Skip to content

Commit 51b09be

Browse files
committed
Datetime
1 parent da5ef25 commit 51b09be

File tree

2 files changed

+14
-12
lines changed

2 files changed

+14
-12
lines changed

README.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -629,7 +629,7 @@ from dateutil.tz import UTC, tzlocal, gettz, resolve_imaginary
629629
<DTn> = DT.fromtimestamp(<real>) # Local time DTn from seconds since Epoch.
630630
<DTa> = DT.fromtimestamp(<real>, <tz.>) # Aware datetime from seconds since Epoch.
631631
```
632-
* **ISO strings come in following forms: `'YYYY-MM-DD'`, `'HH:MM:SS.ffffff[±<offset>]'`, or both separated by a space or a `'T'`. Offset is formatted as: `'HH:MM'`.**
632+
* **ISO strings come in following forms: `'YYYY-MM-DD'`, `'HH:MM:SS.ffffff[±<offset>]'`, or both separated by an arbitrary character. Offset is formatted as: `'HH:MM'`.**
633633
* **On Unix systems Epoch is `'1970-01-01 00:00 UTC'`, `'1970-01-01 01:00 CET'`, ...**
634634

635635
### Decode
@@ -653,8 +653,9 @@ from dateutil.tz import UTC, tzlocal, gettz, resolve_imaginary
653653

654654
### Arithmetics
655655
```python
656-
<D/DT> = <D/DT> ± <TD> # Result can fall into missing hour.
657-
<TD> = <D/DT> - <D/DT> # Ignores time jumps if they share non tzlocal tz.
656+
<D/DT> = <D/DT> ± <TD> # Returned datetime can fall into missing hour.
657+
<TD> = <D/DTn> - <D/DTn> # Returns the difference, ignoring time jumps.
658+
<TD> = <DTa> - <DTa> # Ignores time jumps if they share tzinfo object.
658659
<TD> = <DT_UTC> - <DT_UTC> # Convert DTs to UTC to get the actual delta.
659660
```
660661

@@ -1879,15 +1880,15 @@ Bytes
18791880
```python
18801881
<bytes> = bytes(<coll_of_ints>) # Ints must be in range from 0 to 255.
18811882
<bytes> = bytes(<str>, 'utf-8') # Or: <str>.encode('utf-8')
1882-
<bytes> = <int>.to_bytes(n_bytes, byteorder='big|little', signed=False)
1883+
<bytes> = <int>.to_bytes(n_bytes, byteorder='big/little', signed=False)
18831884
<bytes> = bytes.fromhex('<hex>')
18841885
```
18851886

18861887
### Decode
18871888
```python
18881889
<list> = list(<bytes>) # Returns ints in range from 0 to 255.
18891890
<str> = str(<bytes>, 'utf-8') # Or: <bytes>.decode('utf-8')
1890-
<int> = int.from_bytes(<bytes>, byteorder='big|little', signed=False)
1891+
<int> = int.from_bytes(<bytes>, byteorder='big/little', signed=False)
18911892
'<hex>' = <bytes>.hex()
18921893
```
18931894

@@ -1978,7 +1979,7 @@ Memory View
19781979
<bytes> = <bytes>.join(<coll_of_mviews>) # Joins mviews using bytes object as sep.
19791980
<list> = list(<mview>) # Returns list of ints or floats.
19801981
<str> = str(<mview>, 'utf-8')
1981-
<int> = int.from_bytes(<mview>, byteorder='big|little', signed=False)
1982+
<int> = int.from_bytes(<mview>, byteorder='big/little', signed=False)
19821983
'<hex>' = <mview>.hex()
19831984
```
19841985

index.html

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -681,7 +681,7 @@
681681
</code></pre></div>
682682

683683
<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[±&lt;offset&gt;]'</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[±&lt;offset&gt;]'</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>
685685
<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>
686686
</ul>
687687
<div><h3 id="decode">Decode</h3><pre><code class="python language-python hljs">&lt;str&gt; = &lt;D/T/DT&gt;.isoformat(sep=<span class="hljs-string">'T'</span>) <span class="hljs-comment"># Also timespec='auto/hours/minutes/seconds'.</span>
@@ -701,8 +701,9 @@
701701
<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>
702702
<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>
703703
</ul>
704-
<div><h3 id="arithmetics">Arithmetics</h3><pre><code class="python language-python apache hljs">&lt;D/DT&gt; = &lt;D/DT&gt; ± &lt;TD&gt; <span class="hljs-comment"># Result can fall into missing hour.</span>
705-
&lt;TD&gt; = &lt;D/DT&gt; - &lt;D/DT&gt; <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">&lt;D/DT&gt; = &lt;D/DT&gt; ± &lt;TD&gt; <span class="hljs-comment"># Returned datetime can fall into missing hour.</span>
705+
&lt;TD&gt; = &lt;D/DTn&gt; - &lt;D/DTn&gt; <span class="hljs-comment"># Returns the difference, ignoring time jumps.</span>
706+
&lt;TD&gt; = &lt;DTa&gt; - &lt;DTa&gt; <span class="hljs-comment"># Ignores time jumps if they share tzinfo object.</span>
706707
&lt;TD&gt; = &lt;DT_UTC&gt; - &lt;DT_UTC&gt; <span class="hljs-comment"># Convert DTs to UTC to get the actual delta.</span>
707708
</code></pre></div>
708709

@@ -1671,13 +1672,13 @@
16711672

16721673
<div><h3 id="encode-1">Encode</h3><pre><code class="python language-python hljs">&lt;bytes&gt; = bytes(&lt;coll_of_ints&gt;) <span class="hljs-comment"># Ints must be in range from 0 to 255.</span>
16731674
&lt;bytes&gt; = bytes(&lt;str&gt;, <span class="hljs-string">'utf-8'</span>) <span class="hljs-comment"># Or: &lt;str&gt;.encode('utf-8')</span>
1674-
&lt;bytes&gt; = &lt;int&gt;.to_bytes(n_bytes, byteorder=<span class="hljs-string">'big|little'</span>, signed=<span class="hljs-keyword">False</span>)
1675+
&lt;bytes&gt; = &lt;int&gt;.to_bytes(n_bytes, byteorder=<span class="hljs-string">'big/little'</span>, signed=<span class="hljs-keyword">False</span>)
16751676
&lt;bytes&gt; = bytes.fromhex(<span class="hljs-string">'&lt;hex&gt;'</span>)
16761677
</code></pre></div>
16771678

16781679
<div><h3 id="decode-1">Decode</h3><pre><code class="python language-python hljs">&lt;list&gt; = list(&lt;bytes&gt;) <span class="hljs-comment"># Returns ints in range from 0 to 255.</span>
16791680
&lt;str&gt; = str(&lt;bytes&gt;, <span class="hljs-string">'utf-8'</span>) <span class="hljs-comment"># Or: &lt;bytes&gt;.decode('utf-8')</span>
1680-
&lt;int&gt; = int.from_bytes(&lt;bytes&gt;, byteorder=<span class="hljs-string">'big|little'</span>, signed=<span class="hljs-keyword">False</span>)
1681+
&lt;int&gt; = int.from_bytes(&lt;bytes&gt;, byteorder=<span class="hljs-string">'big/little'</span>, signed=<span class="hljs-keyword">False</span>)
16811682
<span class="hljs-string">'&lt;hex&gt;'</span> = &lt;bytes&gt;.hex()
16821683
</code></pre></div>
16831684

@@ -1752,7 +1753,7 @@
17521753
&lt;bytes&gt; = &lt;bytes&gt;.join(&lt;coll_of_mviews&gt;) <span class="hljs-comment"># Joins mviews using bytes object as sep.</span>
17531754
&lt;list&gt; = list(&lt;mview&gt;) <span class="hljs-comment"># Returns list of ints or floats.</span>
17541755
&lt;str&gt; = str(&lt;mview&gt;, <span class="hljs-string">'utf-8'</span>)
1755-
&lt;int&gt; = int.from_bytes(&lt;mview&gt;, byteorder=<span class="hljs-string">'big|little'</span>, signed=<span class="hljs-keyword">False</span>)
1756+
&lt;int&gt; = int.from_bytes(&lt;mview&gt;, byteorder=<span class="hljs-string">'big/little'</span>, signed=<span class="hljs-keyword">False</span>)
17561757
<span class="hljs-string">'&lt;hex&gt;'</span> = &lt;mview&gt;.hex()
17571758
</code></pre></div>
17581759

0 commit comments

Comments
 (0)