Browse Source

Datetime fix

pull/28/head
Jure Šorn 6 years ago
parent
commit
5c743570ee
1 changed files with 12 additions and 11 deletions
  1. 23
      README.md

23
README.md

@ -456,8 +456,9 @@ from itertools import product, combinations, combinations_with_replacement, perm
Datetime Datetime
-------- --------
* **Module 'datetime' provides 'date' `<D>`, 'time' `<T>`, 'datetime' `<DT>` and 'timedelta' `<TD>` classes.**
* **Time and datetime can be 'aware' `<a>`, meaning they have defined timezone, or 'naive' `<n>`, meaning they don't.**
* **Module 'datetime' provides 'date' `<D>`, 'time' `<T>`, 'datetime' `<DT>` and 'timedelta' `<TD>` classes, all of which are immutable and hashable.**
* **Time and datetime can be 'aware' `<a>`, meaning they have defined timezone, or 'naive' `<n>`, meaning they don't.
* **If object is naive it is presumed to be in system's timezone.**
```python ```python
# $ pip3 install pytz # $ pip3 install pytz
@ -483,6 +484,15 @@ import pytz
<DTa> = DT.now(<tz>) # Aware datetime from current <tz> time. <DTa> = DT.now(<tz>) # Aware datetime from current <tz> time.
``` ```
### Timezone
```python
<tz> = pytz.timezone('<Cont.>/<City>') # Use 'pytz.utc' for UTC.
<DTa> = <DT>.astimezone(<tz>) # Converts datetime to passed timezone.
<Ta/DTa> = <T/DT>.replace(tzinfo=<tz>) # Changes timezone without conversion.
<TD> = <T/DT>.utcoffset() # Returns timezone's current offset from UTC.
<TD> = <T/DT>.dst() # Returns daylight saving time offset.
```
### Encode ### Encode
```python ```python
<D/T/DT> = D/T/DT.fromisoformat(<str>) # From 'YYYY-MM-DD', 'HH:MM:SS.ffffff[+<offset>]' or both. <D/T/DT> = D/T/DT.fromisoformat(<str>) # From 'YYYY-MM-DD', 'HH:MM:SS.ffffff[+<offset>]' or both.
@ -519,15 +529,6 @@ import pytz
* **`'z'` - Timezone offset, ± and 4 digits** * **`'z'` - Timezone offset, ± and 4 digits**
* **`'Z'` - Timezone name** * **`'Z'` - Timezone name**
### Timezone
```python
<tz> = pytz.timezone('<Continent>/<City>') # Use 'pytz.utc' for UTC.
<DTa> = <DT>.astimezone(<tz>) # Converts datetime to passed timezone.
<Ta/DTa> = <T/DT>.replace(tzinfo=<tz>) # Changes timezone without conversion.
<timedelta> = <T/DT>.utcoffset() # Returns timezone's current offset from UTC.
<timedelta> = <T/DT>.dst() # Returns daylight saving time offset.
```
Arguments Arguments
--------- ---------

Loading…
Cancel
Save