From ff47ccf096fb88657048ee16df1e898cbb36bcb1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jure=20=C5=A0orn?= Date: Fri, 10 Jun 2022 03:25:36 +0200 Subject: [PATCH] Datetime --- README.md | 8 ++++---- index.html | 12 ++++++------ 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index aef5170..8d619a9 100644 --- a/README.md +++ b/README.md @@ -604,7 +604,7 @@ from dateutil.tz import UTC, tzlocal, gettz, datetime_exists, resolve_imaginary
= datetime(year, month, day, hour=0, minute=0, second=0, ...) = timedelta(weeks=0, days=0, hours=0, minutes=0, seconds=0, ...) ``` -* **Use `'.weekday()'` to get the day of the week (Mon == 0).** +* **Use `'.weekday()'` to get the day of the week as an int, with Monday being 0.** * **`'fold=1'` means the second pass in case of time jumping back for one hour.** * **Timedelta normalizes arguments to ±days, seconds (< 86 400) and microseconds (< 1M).** @@ -633,16 +633,16 @@ from dateutil.tz import UTC, tzlocal, gettz, datetime_exists, resolve_imaginary = DT.fromtimestamp() # Local time DTn from seconds since the Epoch. = DT.fromtimestamp(, ) # Aware datetime from seconds since the Epoch. ``` -* **ISO strings come in following forms: `'YYYY-MM-DD'`, `'HH:MM:SS.ffffff[±]'`, or both separated by an arbitrary character. Offset is formatted as: `'HH:MM'`.** +* **ISO strings come in following forms: `'YYYY-MM-DD'`, `'HH:MM:SS.mmmuuu[±HH:MM]'`, or both separated by an arbitrary character. All parts following hours are optional.** * **Python uses the Unix Epoch: `'1970-01-01 00:00 UTC'`, `'1970-01-01 01:00 CET'`, ...** ### Decode ```python - = .isoformat(sep='T') # Also timespec='auto/hours/minutes/seconds'. + = .isoformat(sep='T') # Also timespec='auto/hours/minutes/seconds/…'. = .strftime('') # Custom string representation. = .toordinal() # Days since Gregorian NYE 1, ignoring time and tz. = .timestamp() # Seconds since the Epoch, from DTn in local tz. - = .timestamp() # Seconds since the Epoch, from DTa. + = .timestamp() # Seconds since the Epoch, from aware datetime. ``` ### Format diff --git a/index.html b/index.html index f2160f3..c28a2c3 100644 --- a/index.html +++ b/index.html @@ -54,7 +54,7 @@
- +
@@ -536,7 +536,7 @@ to_exclusive = <range>.stop
    -
  • Use '<D/DT>.weekday()' to get the day of the week (Mon == 0).
  • +
  • Use '<D/DT>.weekday()' to get the day of the week as an int, with Monday being 0.
  • 'fold=1' means the second pass in case of time jumping back for one hour.
  • Timedelta normalizes arguments to ±days, seconds (< 86 400) and microseconds (< 1M).
@@ -563,14 +563,14 @@ to_exclusive = <range>.stop
    -
  • ISO strings come in following forms: 'YYYY-MM-DD', 'HH:MM:SS.ffffff[±<offset>]', or both separated by an arbitrary character. Offset is formatted as: 'HH:MM'.
  • +
  • ISO strings come in following forms: 'YYYY-MM-DD', 'HH:MM:SS.mmmuuu[±HH:MM]', or both separated by an arbitrary character. All parts following hours are optional.
  • Python uses the Unix Epoch: '1970-01-01 00:00 UTC', '1970-01-01 01:00 CET', …
-

Decode

<str>    = <D/T/DT>.isoformat(sep='T')      # Also timespec='auto/hours/minutes/seconds'.
+

Decode

<str>    = <D/T/DT>.isoformat(sep='T')      # Also timespec='auto/hours/minutes/seconds/…'.
 <str>    = <D/T/DT>.strftime('<format>')    # Custom string representation.
 <int>    = <D/DT>.toordinal()               # Days since Gregorian NYE 1, ignoring time and tz.
 <float>  = <DTn>.timestamp()                # Seconds since the Epoch, from DTn in local tz.
-<float>  = <DTa>.timestamp()                # Seconds since the Epoch, from DTa.
+<float>  = <DTa>.timestamp()                # Seconds since the Epoch, from aware datetime.
 

Format

>>> dt = datetime.strptime('2015-05-14 23:39:00.00 +2000', '%Y-%m-%d %H:%M:%S.%f %z')
@@ -2901,7 +2901,7 @@ $ pyinstaller script.py --add-data '<path>:.'