Skip to content

Commit 491c927

Browse files
committed
Datetime fix
1 parent 683d439 commit 491c927

File tree

1 file changed

+21
-9
lines changed

1 file changed

+21
-9
lines changed

README.md

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -495,23 +495,35 @@ import pytz
495495

496496
### Encode
497497
```python
498-
<D/T/DT> = D/T/DT.fromisoformat(<str>) # From 'YYYY-MM-DD', 'HH:MM:SS.ffffff[+<offset>]' or both.
499-
<DT> = DT.strptime(<str>, '<format>') # Datetime from string according to <format>.
498+
<D/T/DT> = D/T/DT.fromisoformat(<str>) # From 'YYYY-MM-DD' / 'HH:MM:SS.ffffff[+<offset>]'.
499+
<DT> = DT.strptime(<str>, '<format>') # Datetime from string according to format.
500500
<D/DTn> = D/DT.fromordinal(<int>) # Date or datetime from days since Christ.
501-
<D/DTn> = D/DT.fromtimestamp(<real>) # Date or datetime from seconds since Epoch in local time.
502-
<DTn> = DT.utcfromtimestamp(<real>) # Naive datetime from seconds since Epoch in UTC time.
503-
<DTa> = DT.fromtimestamp(<real>, <tz>) # Aware datetime from seconds since Epoch in <tz> time.
501+
<D/DTn> = D/DT.fromtimestamp(<real>) # D/DT from seconds since Epoch in local time.
502+
<DTn> = DT.utcfromtimestamp(<real>) # Naive DT from seconds since Epoch in UTC time.
503+
<DTa> = DT.fromtimestamp(<real>, <tz>) # Aware DT from seconds since Epoch in tz time.
504504
```
505505
* **On Unix systems Epoch is `'1970-01-01 00:00 UTC'`, `'1970-01-01 01:00 CET'`, ...**
506506

507507
### Decode
508508
```python
509-
<str> = <D/T/DT>.isoformat() # 'YYYY-MM-DD', 'HH:MM:SS.ffffff[+<offset>]' or both.
510-
<str> = <D/T/DT>.strftime('<format>') # Returns customized string representation.
511-
<int> = <D/DT>.toordinal() # Returns days since Christ ignoring time and timezone.
512-
<float> = <DT>.timestamp() # Returns seconds since Epoch in local time or tz if set.
509+
<str> = <D/T/DT>.isoformat() # 'YYYY-MM-DD' / 'HH:MM:SS.ffffff[+<offset>]'.
510+
<str> = <D/T/DT>.strftime('<format>') # Customized string representation.
511+
<int> = <D/DT>.toordinal() # Days since Christ, ignoring time and timezone.
512+
<float> = <DT>.timestamp() # Seconds since Epoch in local time or tz if set.
513513
```
514514

515+
### ISO Format
516+
```python
517+
date == 'YYYY-MM-DD'
518+
time == 'HH:MM:SS.ffffff[+<offset>]'
519+
datetime == 'YYYY-MM-DDTHH:MM:SS.ffffff[+<offset>]'
520+
```
521+
522+
* **Date: `'YYYY-MM-DD'`.**
523+
* **Time: `'HH:MM:SS.ffffff[+<offset>]'`.**
524+
* **Datetime: `'YYYY-MM-DDTHH:MM:SS.ffffff[+<offset>]'`.**
525+
526+
515527
### Format
516528
```python
517529
>>> dt = datetime.strptime('2015-05-14 23:39:00', '%Y-%m-%d %H:%M:%S')

0 commit comments

Comments
 (0)