Browse Source

Datetime

pull/109/merge
Jure Šorn 1 year ago
parent
commit
ac835f5958
2 changed files with 6 additions and 6 deletions
  1. 4
      README.md
  2. 8
      index.html

4
README.md

@ -647,11 +647,11 @@ from dateutil.tz import UTC, tzlocal, gettz, datetime_exists, resolve_imaginary
### Format
```python
>>> dt = datetime.strptime('2015-05-14 23:39:00.00 +2000', '%Y-%m-%d %H:%M:%S.%f %z')
>>> dt = datetime.strptime('2015-05-14 23:39:00.00 +0200', '%Y-%m-%d %H:%M:%S.%f %z')
>>> dt.strftime("%A, %dth of %B '%y, %I:%M%p %Z")
"Thursday, 14th of May '15, 11:39PM UTC+02:00"
```
* **`'%Z'` only accepts `'UTC/GMT'` and local timezone's code. `'%z'` also accepts `'±HH:MM'`.**
* **Format code `'%z'` accepts `'±HH[:]MM'` and returns `'±HHMM'` (or `''` if datetime is naive).**
* **For abbreviated weekday and month use `'%a'` and `'%b'`.**
### Arithmetics

8
index.html

@ -54,7 +54,7 @@
<body>
<header>
<aside>April 8, 2023</aside>
<aside>April 9, 2023</aside>
<a href="https://gto76.github.io" rel="author">Jure Šorn</a>
</header>
@ -573,13 +573,13 @@ Point(x=<span class="hljs-number">1</span>, y=<span class="hljs-number">2</span>
&lt;float&gt; = &lt;DTa&gt;.timestamp() <span class="hljs-comment"># Seconds since the Epoch, from aware datetime.</span>
</code></pre></div>
<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>)
<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 +0200'</span>, <span class="hljs-string">'%Y-%m-%d %H:%M:%S.%f %z'</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>dt.strftime(<span class="hljs-string">"%A, %dth of %B '%y, %I:%M%p %Z"</span>)
<span class="hljs-string">"Thursday, 14th of May '15, 11:39PM UTC+02:00"</span>
</code></pre></div>
<ul>
<li><strong><code class="python hljs"><span class="hljs-string">'%Z'</span></code> only accepts <code class="python hljs"><span class="hljs-string">'UTC/GMT'</span></code> and local timezone's code. <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>Format code <code class="python hljs"><span class="hljs-string">'%z'</span></code> accepts <code class="python hljs"><span class="hljs-string">'±HH[:]MM'</span></code> and returns <code class="python hljs"><span class="hljs-string">'±HHMM'</span></code> (or <code class="python hljs"><span class="hljs-string">''</span></code> if datetime is naive).</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;D/DT&gt; = &lt;D/DT&gt; ± &lt;TD&gt; <span class="hljs-comment"># Returned datetime can fall into missing hour.</span>
@ -2934,7 +2934,7 @@ $ pyinstaller script.py --add-data '&lt;path&gt;:.' <span class="hljs-comment">
<footer>
<aside>April 8, 2023</aside>
<aside>April 9, 2023</aside>
<a href="https://gto76.github.io" rel="author">Jure Šorn</a>
</footer>

Loading…
Cancel
Save