Skip to content

Commit ff47ccf

Browse files
committed
Datetime
1 parent 3d151bc commit ff47ccf

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -604,7 +604,7 @@ from dateutil.tz import UTC, tzlocal, gettz, datetime_exists, resolve_imaginary
604604
<DT> = datetime(year, month, day, hour=0, minute=0, second=0, ...)
605605
<TD> = timedelta(weeks=0, days=0, hours=0, minutes=0, seconds=0, ...)
606606
```
607-
* **Use `'<D/DT>.weekday()'` to get the day of the week (Mon == 0).**
607+
* **Use `'<D/DT>.weekday()'` to get the day of the week as an int, with Monday being 0.**
608608
* **`'fold=1'` means the second pass in case of time jumping back for one hour.**
609609
* **Timedelta normalizes arguments to ±days, seconds (< 86 400) and microseconds (< 1M).**
610610

@@ -633,16 +633,16 @@ from dateutil.tz import UTC, tzlocal, gettz, datetime_exists, resolve_imaginary
633633
<DTn> = DT.fromtimestamp(<real>) # Local time DTn from seconds since the Epoch.
634634
<DTa> = DT.fromtimestamp(<real>, <tz.>) # Aware datetime from seconds since the Epoch.
635635
```
636-
* **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'`.**
636+
* **ISO strings come in following forms: `'YYYY-MM-DD'`, `'HH:MM:SS.mmmuuu[±HH:MM]'`, or both separated by an arbitrary character. All parts following hours are optional.**
637637
* **Python uses the Unix Epoch: `'1970-01-01 00:00 UTC'`, `'1970-01-01 01:00 CET'`, ...**
638638

639639
### Decode
640640
```python
641-
<str> = <D/T/DT>.isoformat(sep='T') # Also timespec='auto/hours/minutes/seconds'.
641+
<str> = <D/T/DT>.isoformat(sep='T') # Also timespec='auto/hours/minutes/seconds/…'.
642642
<str> = <D/T/DT>.strftime('<format>') # Custom string representation.
643643
<int> = <D/DT>.toordinal() # Days since Gregorian NYE 1, ignoring time and tz.
644644
<float> = <DTn>.timestamp() # Seconds since the Epoch, from DTn in local tz.
645-
<float> = <DTa>.timestamp() # Seconds since the Epoch, from DTa.
645+
<float> = <DTa>.timestamp() # Seconds since the Epoch, from aware datetime.
646646
```
647647

648648
### Format

index.html

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454

5555
<body>
5656
<header>
57-
<aside>June 7, 2022</aside>
57+
<aside>June 10, 2022</aside>
5858
<a href="https://gto76.github.io" rel="author">Jure Šorn</a>
5959
</header>
6060

@@ -536,7 +536,7 @@
536536
</code></pre></div>
537537

538538
<ul>
539-
<li><strong>Use <code class="python hljs"><span class="hljs-string">'&lt;D/DT&gt;.weekday()'</span></code> to get the day of the week (Mon == 0).</strong></li>
539+
<li><strong>Use <code class="python hljs"><span class="hljs-string">'&lt;D/DT&gt;.weekday()'</span></code> to get the day of the week as an int, with Monday being 0.</strong></li>
540540
<li><strong><code class="python hljs"><span class="hljs-string">'fold=1'</span></code> means the second pass in case of time jumping back for one hour.</strong></li>
541541
<li><strong>Timedelta normalizes arguments to ±days, seconds (&lt; 86 400) and microseconds (&lt; 1M).</strong></li>
542542
</ul>
@@ -563,14 +563,14 @@
563563
</code></pre></div>
564564

565565
<ul>
566-
<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>
566+
<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.mmmuuu[±HH:MM]'</span></code>, or both separated by an arbitrary character. All parts following hours are optional.</strong></li>
567567
<li><strong>Python uses the Unix Epoch: <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>
568568
</ul>
569-
<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>
569+
<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>
570570
&lt;str&gt; = &lt;D/T/DT&gt;.strftime(<span class="hljs-string">'&lt;format&gt;'</span>) <span class="hljs-comment"># Custom string representation.</span>
571571
&lt;int&gt; = &lt;D/DT&gt;.toordinal() <span class="hljs-comment"># Days since Gregorian NYE 1, ignoring time and tz.</span>
572572
&lt;float&gt; = &lt;DTn&gt;.timestamp() <span class="hljs-comment"># Seconds since the Epoch, from DTn in local tz.</span>
573-
&lt;float&gt; = &lt;DTa&gt;.timestamp() <span class="hljs-comment"># Seconds since the Epoch, from DTa.</span>
573+
&lt;float&gt; = &lt;DTa&gt;.timestamp() <span class="hljs-comment"># Seconds since the Epoch, from aware datetime.</span>
574574
</code></pre></div>
575575

576576
<div><h3 id="format-1">Format</h3><pre><code class="python language-python hljs"><span class="hljs-meta">&gt;&gt;&gt; </span>dt = datetime.strptime(<span class="hljs-string">'2015-05-14 23:39:00.00 +2000'</span>, <span class="hljs-string">'%Y-%m-%d %H:%M:%S.%f %z'</span>)
@@ -2901,7 +2901,7 @@
29012901

29022902

29032903
<footer>
2904-
<aside>June 7, 2022</aside>
2904+
<aside>June 10, 2022</aside>
29052905
<a href="https://gto76.github.io" rel="author">Jure Šorn</a>
29062906
</footer>
29072907

0 commit comments

Comments
 (0)