@ -561,19 +561,20 @@ from dateutil.tz import UTC, tzlocal, gettz
```python
```python
<D/DTn> = D/DT.today() # Current local date or naive datetime.
<D/DTn> = D/DT.today() # Current local date or naive datetime.
<DTn> = DT.utcnow() # Naive datetime from current UTC time.
<DTn> = DT.utcnow() # Naive datetime from current UTC time.
<DTa> = DT.now(<tz>) # Aware datetime from current tz time.
<DTa> = DT.now(<tzinfo>) # Aware datetime from current tz time.
```
```
* **To extract time use `'<DTn>.time()'` or `'<DTa>.timetz()'`.**
### Timezone
### Timezone
```python
```python
<tz> = UTC # UTC timezone. London without DST.
<tz> = tzlocal() # Local timezone.
<tz> = gettz('<Cont.>/<City>') # Timezone from 'Continent/City_Name' str.
<tzinfo> = UTC # UTC timezone. London without DST.
<tzinfo> = tzlocal() # Local timezone.
<tzinfo> = gettz('<Cont.>/<City>') # Timezone from 'Continent/City_Name' str.
```
```
```python
```python
<DTa> = <DT>.astimezone(<tz>) # Datetime, converted to passed timezone.
<Ta/DTa> = <T/DT>.replace(tzinfo=<tz>) # Unconverted object with new timezone.
<DTa> = <DT>.astimezone(<tzinfo>) # Datetime, converted to passed timezone.
<Ta/DTa> = <T/DT>.replace(tzinfo=<tzinfo>) # Unconverted object with new timezone.
```
```
### Encode
### Encode
@ -581,7 +582,7 @@ from dateutil.tz import UTC, tzlocal, gettz
<D/T/DT> = D/T/DT.fromisoformat('<iso>') # Object from ISO string.
<D/T/DT> = D/T/DT.fromisoformat('<iso>') # Object from ISO string.
<DT> = DT.strptime(<str>, '<format>') # Datetime from str, according to format.
<DT> = DT.strptime(<str>, '<format>') # Datetime from str, according to format.
<D/DTn> = D/DT.fromordinal(<int>) # D/DTn from days since Christ.
<D/DTn> = D/DT.fromordinal(<int>) # D/DTn from days since Christ.
<DTa> = DT.fromtimestamp(<real>, <tz>) # DTa from seconds since Epoch in tz time.
<DTa> = DT.fromtimestamp(<real>, <tz.>) # DTa from seconds since Epoch in tz time.
```
```
* **ISO strings come in following forms: `'YYYY-MM-DD'`, `'HH:MM:SS.ffffff[±<offset>]'`, or both separated by `'T'`. Offset is formatted as: `'HH:MM'`.**
* **ISO strings come in following forms: `'YYYY-MM-DD'`, `'HH:MM:SS.ffffff[±<offset>]'`, or both separated by `'T'`. Offset is formatted as: `'HH:MM'`.**
* **On Unix systems Epoch is `'1970-01-01 00:00 UTC'`, `'1970-01-01 01:00 CET'`, ...**
* **On Unix systems Epoch is `'1970-01-01 00:00 UTC'`, `'1970-01-01 01:00 CET'`, ...**
@ -601,10 +602,15 @@ from dateutil.tz import UTC, tzlocal, gettz
>>> dt.strftime("%A, %dth of %B '%y, %I:%M%p %Z")
>>> dt.strftime("%A, %dth of %B '%y, %I:%M%p %Z")
"Thursday, 14th of May '15, 11:39PM UTC+02:00"
"Thursday, 14th of May '15, 11:39PM UTC+02:00"
```
```
* **For abbreviated weekday and month use `'%a'` and `'%b'`.**
#### Rest of the codes:
* **`'a'` - Weekday, abbreviated name.**
* **`'b'` - Month, abbreviated name.**
### Arithmetics
```python
<D/DT> = <D/DT> ± <TD>
<TD> = <TD> ± <TD>
<TD> = <TD> */ <real>
<float> = <TD> / <TD>
```
Arguments
Arguments
@ -1350,7 +1356,7 @@ cwd = Path()
```
```
```python
```python
<iter> = <Path>.iterdir() # Iterator with filenames located at path.
<iter> = <Path>.iterdir() # Iterator of filenames located at path.
<iter> = <Path>.glob('<pattern>') # Filenames matching the wildcard pattern.
<iter> = <Path>.glob('<pattern>') # Filenames matching the wildcard pattern.
<pre><codeclass="python language-python hljs"><D/DTn> = D/DT.today() <spanclass="hljs-comment"># Current local date or naive datetime.</span>
<pre><codeclass="python language-python hljs"><D/DTn> = D/DT.today() <spanclass="hljs-comment"># Current local date or naive datetime.</span>
<DTn> = DT.utcnow() <spanclass="hljs-comment"># Naive datetime from current UTC time.</span>
<DTn> = DT.utcnow() <spanclass="hljs-comment"># Naive datetime from current UTC time.</span>
<DTa> = DT.now(<tz>)<spanclass="hljs-comment"># Aware datetime from current tz time.</span>
<DTa> = DT.now(<tzinfo>) <spanclass="hljs-comment"># Aware datetime from current tz time.</span>
</code></pre>
</code></pre>
<ul>
<li><strong>To extract time use <codeclass="python hljs"><spanclass="hljs-string">'<DTn>.time()'</span></code> or <codeclass="python hljs"><spanclass="hljs-string">'<DTa>.timetz()'</span></code>.</strong></li>
</ul>
<h3id="timezone">Timezone</h3>
<h3id="timezone">Timezone</h3>
<pre><codeclass="python language-python hljs"><tz> = UTC <spanclass="hljs-comment"># UTC timezone. London without DST.</span>
<tz> = tzlocal() <spanclass="hljs-comment"># Local timezone.</span>
<tz> = gettz(<spanclass="hljs-string">'<Cont.>/<City>'</span>) <spanclass="hljs-comment"># Timezone from 'Continent/City_Name' str.</span>
<pre><codeclass="python language-python hljs"><tzinfo> = UTC <spanclass="hljs-comment"># UTC timezone. London without DST.</span>
<tzinfo> = tzlocal() <spanclass="hljs-comment"># Local timezone.</span>
<tzinfo> = gettz(<spanclass="hljs-string">'<Cont.>/<City>'</span>) <spanclass="hljs-comment"># Timezone from 'Continent/City_Name' str.</span>
<Ta/DTa> = <T/DT>.replace(tzinfo=<tzinfo>) <spanclass="hljs-comment"># Unconverted object with new timezone.</span>
</code></pre>
</code></pre>
<h3id="encode">Encode</h3>
<h3id="encode">Encode</h3>
<pre><codeclass="python language-python apache hljs"><D/T/DT> = D/T/DT.fromisoformat(<spanclass="hljs-string">'<iso>'</span>) <spanclass="hljs-comment"># Object from ISO string.</span>
<pre><codeclass="python language-python apache hljs"><D/T/DT> = D/T/DT.fromisoformat(<spanclass="hljs-string">'<iso>'</span>) <spanclass="hljs-comment"># Object from ISO string.</span>
<DT> = DT.strptime(<str>, <spanclass="hljs-string">'<format>'</span>) <spanclass="hljs-comment"># Datetime from str, according to format.</span>
<DT> = DT.strptime(<str>, <spanclass="hljs-string">'<format>'</span>) <spanclass="hljs-comment"># Datetime from str, according to format.</span>
<D/DTn> = D/DT.fromordinal(<int>) <spanclass="hljs-comment"># D/DTn from days since Christ.</span>
<D/DTn> = D/DT.fromordinal(<int>) <spanclass="hljs-comment"># D/DTn from days since Christ.</span>
<DTa> = DT.fromtimestamp(<real>, <tz>)<spanclass="hljs-comment"># DTa from seconds since Epoch in tz time.</span>
<DTa> = DT.fromtimestamp(<real>, <tz.>) <spanclass="hljs-comment"># DTa from seconds since Epoch in tz time.</span>
</code></pre>
</code></pre>
<ul>
<ul>
<li><strong>ISO strings come in following forms: <codeclass="python hljs"><spanclass="hljs-string">'YYYY-MM-DD'</span></code>, <codeclass="python hljs"><spanclass="hljs-string">'HH:MM:SS.ffffff[±<offset>]'</span></code>, or both separated by <codeclass="python hljs"><spanclass="hljs-string">'T'</span></code>. Offset is formatted as: <codeclass="python hljs"><spanclass="hljs-string">'HH:MM'</span></code>.</strong></li>
<li><strong>ISO strings come in following forms: <codeclass="python hljs"><spanclass="hljs-string">'YYYY-MM-DD'</span></code>, <codeclass="python hljs"><spanclass="hljs-string">'HH:MM:SS.ffffff[±<offset>]'</span></code>, or both separated by <codeclass="python hljs"><spanclass="hljs-string">'T'</span></code>. Offset is formatted as: <codeclass="python hljs"><spanclass="hljs-string">'HH:MM'</span></code>.</strong></li>
@ -631,11 +634,15 @@ shuffle(<list>)
<spanclass="hljs-meta">>>></span>dt.strftime(<spanclass="hljs-string">"%A, %dth of %B '%y, %I:%M%p %Z"</span>)
<spanclass="hljs-meta">>>></span>dt.strftime(<spanclass="hljs-string">"%A, %dth of %B '%y, %I:%M%p %Z"</span>)
<spanclass="hljs-string">"Thursday, 14th of May '15, 11:39PM UTC+02:00"</span>
<spanclass="hljs-string">"Thursday, 14th of May '15, 11:39PM UTC+02:00"</span>
<li><strong>For abbreviated weekday and month use <codeclass="python hljs"><spanclass="hljs-string">'%a'</span></code> and <codeclass="python hljs"><spanclass="hljs-string">'%b'</span></code>.</strong></li>
<pre><codeclass="python language-python hljs"><iter> = <Path>.iterdir() <spanclass="hljs-comment"># Iterator with filenames located at path.</span>
<pre><codeclass="python language-python hljs"><iter> = <Path>.iterdir() <spanclass="hljs-comment"># Iterator of filenames located at path.</span>
<iter> = <Path>.glob(<spanclass="hljs-string">'<pattern>'</span>) <spanclass="hljs-comment"># Filenames matching the wildcard pattern.</span>
<iter> = <Path>.glob(<spanclass="hljs-string">'<pattern>'</span>) <spanclass="hljs-comment"># Filenames matching the wildcard pattern.</span>
</code></pre>
</code></pre>
<pre><codeclass="python language-python hljs"><str> = str(<Path>) <spanclass="hljs-comment"># Returns path as a string.</span>
<pre><codeclass="python language-python hljs"><str> = str(<Path>) <spanclass="hljs-comment"># Returns path as a string.</span>