Browse Source

Datetime

pull/46/head
Jure Šorn 5 years ago
parent
commit
7501dca527
3 changed files with 12 additions and 8 deletions
  1. 8
      README.md
  2. 8
      index.html
  3. 4
      parse.js

8
README.md

@ -590,7 +590,7 @@ Datetime
```python
from datetime import date, time, datetime, timedelta
from dateutil.tz import UTC, tzlocal, gettz
from dateutil.tz import UTC, tzlocal, gettz, resolve_imaginary
```
### Constructors
@ -603,6 +603,7 @@ from dateutil.tz import UTC, tzlocal, gettz
```
* **Use `'<D/DT>.weekday()'` to get the day of the week (Mon == 0).**
* **`'fold=1'` means second pass in case of time jumping back for one hour.**
* **`'<DT> = resolve_imaginary(<DT>)'` fixes DTs that fall into missing hour.**
### Now
```python
@ -652,12 +653,11 @@ from dateutil.tz import UTC, tzlocal, gettz
"Thursday, 14th of May '15, 11:39PM UTC+02:00"
```
* **When parsing, `'%z'` also accepts `'±HH:MM'`.**
* **For abbreviated weekday and month use `'%a'` and `'%b'`.**
### Arithmetics
```python
<TD> = <D/DT> - <D/DT>
<D/DT> = <D/DT> ± <TD>
<TD> = <D/DT> - <D/DT> # Returns the difference between wall times.
<D/DT> = <D/DT> ± <TD> # Result can be an imaginary time.
<TD> = <TD> ± <TD>
<TD> = <TD> * <real>
```

8
index.html

@ -644,7 +644,7 @@ shuffle(&lt;list&gt;)
<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>
<li><strong>If object is naive it is presumed to be in the system's timezone.</strong></li>
</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
<span class="hljs-keyword">from</span> dateutil.tz <span class="hljs-keyword">import</span> UTC, tzlocal, gettz
<span class="hljs-keyword">from</span> dateutil.tz <span class="hljs-keyword">import</span> UTC, tzlocal, gettz, resolve_imaginary
</code></pre></div>
@ -658,6 +658,7 @@ shuffle(&lt;list&gt;)
<ul>
<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>
<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>
<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>
</ul>
<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>
&lt;DTn&gt; = DT.utcnow() <span class="hljs-comment"># Naive datetime from current UTC time.</span>
@ -701,10 +702,9 @@ shuffle(&lt;list&gt;)
<ul>
<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>
<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>
</ul>
<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;
&lt;D/DT&gt; = &lt;D/DT&gt; ± &lt;TD&gt;
<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>
&lt;D/DT&gt; = &lt;D/DT&gt; ± &lt;TD&gt; <span class="hljs-comment"># Result can be an imaginary time.</span>
&lt;TD&gt; = &lt;TD&gt; ± &lt;TD&gt;
&lt;TD&gt; = &lt;TD&gt; * &lt;real&gt;
</code></pre></div>

4
parse.js

@ -63,6 +63,9 @@ const DATACLASS =
'&lt;class&gt; = make_dataclass(<span class="hljs-string">\'&lt;class_name&gt;\'</span>, &lt;coll_of_tuples&gt;)\n' +
'&lt;tuple&gt; = (<span class="hljs-string">\'&lt;attr_name&gt;\'</span>, &lt;type&gt; [, &lt;default_value&gt;])</code>';
const DATETIME =
'<code class="python language-python hljs"><span class="hljs-string">\'&lt;DT&gt; = resolve_imaginary(&lt;DT&gt;)\'</span></code>';
function main() {
const html = getMd();
@ -156,6 +159,7 @@ function fixHighlights() {
$(`code:contains(@lru_cache(maxsize=None))`).html(LRU_CACHE);
$(`code:contains(\'<class_name>\', <parents_tuple>, <attributes_dict>)`).html(TYPE);
$(`code:contains(make_dataclass(\'<class_name>\')`).html(DATACLASS);
$(`code:contains((<DT>))`).html(DATETIME)
}
function preventPageBreaks() {

Loading…
Cancel
Save