Skip to content

Commit 7501dca

Browse files
committed
Datetime
1 parent 9610b43 commit 7501dca

File tree

3 files changed

+12
-8
lines changed

3 files changed

+12
-8
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -590,7 +590,7 @@ Datetime
590590

591591
```python
592592
from datetime import date, time, datetime, timedelta
593-
from dateutil.tz import UTC, tzlocal, gettz
593+
from dateutil.tz import UTC, tzlocal, gettz, resolve_imaginary
594594
```
595595

596596
### Constructors
@@ -603,6 +603,7 @@ from dateutil.tz import UTC, tzlocal, gettz
603603
```
604604
* **Use `'<D/DT>.weekday()'` to get the day of the week (Mon == 0).**
605605
* **`'fold=1'` means second pass in case of time jumping back for one hour.**
606+
* **`'<DT> = resolve_imaginary(<DT>)'` fixes DTs that fall into missing hour.**
606607

607608
### Now
608609
```python
@@ -652,12 +653,11 @@ from dateutil.tz import UTC, tzlocal, gettz
652653
"Thursday, 14th of May '15, 11:39PM UTC+02:00"
653654
```
654655
* **When parsing, `'%z'` also accepts `'±HH:MM'`.**
655-
* **For abbreviated weekday and month use `'%a'` and `'%b'`.**
656656

657657
### Arithmetics
658658
```python
659-
<TD> = <D/DT> - <D/DT>
660-
<D/DT> = <D/DT> ± <TD>
659+
<TD> = <D/DT> - <D/DT> # Returns the difference between wall times.
660+
<D/DT> = <D/DT> ± <TD> # Result can be an imaginary time.
661661
<TD> = <TD> ± <TD>
662662
<TD> = <TD> * <real>
663663
```

index.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -644,7 +644,7 @@
644644
<li><strong>Time and datetime can be 'aware' <code class="apache hljs"><span class="hljs-section">&lt;a&gt;</span></code>, meaning they have defined timezone, or 'naive' <code class="apache hljs"><span class="hljs-section">&lt;n&gt;</span></code>, meaning they don't.</strong></li>
645645
<li><strong>If object is naive it is presumed to be in the system's timezone.</strong></li>
646646
</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
648648
</code></pre></div>
649649

650650

@@ -658,6 +658,7 @@
658658
<ul>
659659
<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>
660660
<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">'&lt;DT&gt; = resolve_imaginary(&lt;DT&gt;)'</span></code></code> fixes DTs that fall into missing hour.</strong></li>
661662
</ul>
662663
<div><h3 id="now">Now</h3><pre><code class="python language-python hljs">&lt;D/DTn&gt; = D/DT.today() <span class="hljs-comment"># Current local date or naive datetime.</span>
663664
&lt;DTn&gt; = DT.utcnow() <span class="hljs-comment"># Naive datetime from current UTC time.</span>
@@ -701,10 +702,9 @@
701702

702703
<ul>
703704
<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>
705705
</ul>
706-
<div><h3 id="arithmetics">Arithmetics</h3><pre><code class="python language-python apache hljs">&lt;TD&gt; = &lt;D/DT&gt; - &lt;D/DT&gt;
707-
&lt;D/DT&gt; = &lt;D/DT&gt; ± &lt;TD&gt;
706+
<div><h3 id="arithmetics">Arithmetics</h3><pre><code class="python language-python apache hljs">&lt;TD&gt; = &lt;D/DT&gt; - &lt;D/DT&gt; <span class="hljs-comment"># Returns the difference between wall times.</span>
707+
&lt;D/DT&gt; = &lt;D/DT&gt; ± &lt;TD&gt; <span class="hljs-comment"># Result can be an imaginary time.</span>
708708
&lt;TD&gt; = &lt;TD&gt; ± &lt;TD&gt;
709709
&lt;TD&gt; = &lt;TD&gt; * &lt;real&gt;
710710
</code></pre></div>

parse.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ const DATACLASS =
6363
'&lt;class&gt; = make_dataclass(<span class="hljs-string">\'&lt;class_name&gt;\'</span>, &lt;coll_of_tuples&gt;)\n' +
6464
'&lt;tuple&gt; = (<span class="hljs-string">\'&lt;attr_name&gt;\'</span>, &lt;type&gt; [, &lt;default_value&gt;])</code>';
6565

66+
const DATETIME =
67+
'<code class="python language-python hljs"><span class="hljs-string">\'&lt;DT&gt; = resolve_imaginary(&lt;DT&gt;)\'</span></code>';
68+
6669

6770
function main() {
6871
const html = getMd();
@@ -156,6 +159,7 @@ function fixHighlights() {
156159
$(`code:contains(@lru_cache(maxsize=None))`).html(LRU_CACHE);
157160
$(`code:contains(\'<class_name>\', <parents_tuple>, <attributes_dict>)`).html(TYPE);
158161
$(`code:contains(make_dataclass(\'<class_name>\')`).html(DATACLASS);
162+
$(`code:contains((<DT>))`).html(DATETIME)
159163
}
160164

161165
function preventPageBreaks() {

0 commit comments

Comments
 (0)