From 491c9271eadedc521fa9f6bac2d44bfc3280129a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jure=20=C5=A0orn?= Date: Fri, 15 Mar 2019 02:01:22 +0100 Subject: [PATCH] Datetime fix --- README.md | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 7d602e7..339f4a7 100644 --- a/README.md +++ b/README.md @@ -495,23 +495,35 @@ import pytz ### Encode ```python - = D/T/DT.fromisoformat() # From 'YYYY-MM-DD', 'HH:MM:SS.ffffff[+]' or both. -
= DT.strptime(, '') # Datetime from string according to . + = D/T/DT.fromisoformat() # From 'YYYY-MM-DD' / 'HH:MM:SS.ffffff[+]'. +
= DT.strptime(, '') # Datetime from string according to format. = D/DT.fromordinal() # Date or datetime from days since Christ. - = D/DT.fromtimestamp() # Date or datetime from seconds since Epoch in local time. - = DT.utcfromtimestamp() # Naive datetime from seconds since Epoch in UTC time. - = DT.fromtimestamp(, ) # Aware datetime from seconds since Epoch in time. + = D/DT.fromtimestamp() # D/DT from seconds since Epoch in local time. + = DT.utcfromtimestamp() # Naive DT from seconds since Epoch in UTC time. + = DT.fromtimestamp(, ) # Aware DT from seconds since Epoch in tz time. ``` * **On Unix systems Epoch is `'1970-01-01 00:00 UTC'`, `'1970-01-01 01:00 CET'`, ...** ### Decode ```python - = .isoformat() # 'YYYY-MM-DD', 'HH:MM:SS.ffffff[+]' or both. - = .strftime('') # Returns customized string representation. - = .toordinal() # Returns days since Christ ignoring time and timezone. - =
.timestamp() # Returns seconds since Epoch in local time or tz if set. + = .isoformat() # 'YYYY-MM-DD' / 'HH:MM:SS.ffffff[+]'. + = .strftime('') # Customized string representation. + = .toordinal() # Days since Christ, ignoring time and timezone. + =
.timestamp() # Seconds since Epoch in local time or tz if set. ``` +### ISO Format +```python +date == 'YYYY-MM-DD' +time == 'HH:MM:SS.ffffff[+]' +datetime == 'YYYY-MM-DDTHH:MM:SS.ffffff[+]' +``` + +* **Date: `'YYYY-MM-DD'`.** +* **Time: `'HH:MM:SS.ffffff[+]'`.** +* **Datetime: `'YYYY-MM-DDTHH:MM:SS.ffffff[+]'`.** + + ### Format ```python >>> dt = datetime.strptime('2015-05-14 23:39:00', '%Y-%m-%d %H:%M:%S')