• Home
  • Raw
  • Download

Lines Matching +full:not +full:- +full:date

1 :mod:`datetime` --- Basic date and time types
5 :synopsis: Basic date and time types.
13 --------------
19 While date and time arithmetic is supported, the focus of the implementation is
34 Third-party library with expanded time zone and parsing support.
36 .. _datetime-naive-aware:
39 -----------------------
41 Date and time objects may be categorized as "aware" or "naive" depending on
42 whether or not they include timezone information.
47 An aware object represents a specific moment in time that is not open to
50 A **naive** object does not contain enough information to unambiguously locate
51 itself relative to other date/time objects. Whether a naive object represents
72 ---------
78 The smallest year number allowed in a :class:`date` or :class:`.datetime` object.
84 The largest year number allowed in a :class:`date` or :class:`.datetime` object.
94 ---------------
96 .. class:: date
99 An idealized naive date, assuming the current Gregorian calendar always was, and
116 A combination of a date and a time. Attributes: :attr:`year`, :attr:`month`,
124 A duration expressing the difference between two :class:`date`, :class:`.time`,
153 date
159 The :class:`date`, :class:`.datetime`, :class:`.time`, and :class:`timezone` types
162 - Objects of these types are immutable.
163 - Objects of these types are :term:`hashable`, meaning that they can be used as
165 - Objects of these types support efficient pickling via the :mod:`pickle` module.
170 Objects of the :class:`date` type are always naive.
176 1. ``d.tzinfo`` is not ``None``
177 2. ``d.tzinfo.utcoffset(d)`` does not return ``None``
183 1. ``t.tzinfo`` is not ``None``
184 2. ``t.tzinfo.utcoffset(None)`` does not return ``None``.
191 .. _datetime-timedelta:
194 --------------------------
217 * ``-999999999 <= days <= 999999999``
240 round-half-to-even tiebreaker. If no argument is a float, the
251 >>> d = timedelta(microseconds=-1)
253 (-1, 86399, 999999)
260 The most negative :class:`timedelta` object, ``timedelta(-999999999)``.
271 The smallest possible difference between non-equal :class:`timedelta` objects,
274 Note that, because of normalization, ``timedelta.max`` > ``-timedelta.min``.
275 ``-timedelta.max`` is not representable as a :class:`timedelta` object.
277 Instance attributes (read-only):
279 +------------------+--------------------------------------------+
282 | ``days`` | Between -999999999 and 999999999 inclusive |
283 +------------------+--------------------------------------------+
285 +------------------+--------------------------------------------+
287 +------------------+--------------------------------------------+
293 +--------------------------------+-----------------------------------------------+
296 | ``t1 = t2 + t3`` | Sum of *t2* and *t3*. Afterwards *t1*-*t2* == |
297 | | *t3* and *t1*-*t3* == *t2* are true. (1) |
298 +--------------------------------+-----------------------------------------------+
299 | ``t1 = t2 - t3`` | Difference of *t2* and *t3*. Afterwards *t1* |
300 | | == *t2* - *t3* and *t2* == *t1* + *t3* are |
302 +--------------------------------+-----------------------------------------------+
306 +--------------------------------+-----------------------------------------------+
307 | | In general, *t1* \* i == *t1* \* (i-1) + *t1* |
309 +--------------------------------+-----------------------------------------------+
312 | | timedelta.resolution using round-half-to-even.|
313 +--------------------------------+-----------------------------------------------+
317 +--------------------------------+-----------------------------------------------+
320 | | timedelta.resolution using round-half-to-even.|
321 +--------------------------------+-----------------------------------------------+
325 +--------------------------------+-----------------------------------------------+
328 +--------------------------------+-----------------------------------------------+
333 +--------------------------------+-----------------------------------------------+
336 +--------------------------------+-----------------------------------------------+
337 | ``-t1`` | equivalent to |
338 | | :class:`timedelta`\ (-*t1.days*, |
339 | | -*t1.seconds*, -*t1.microseconds*), |
340 | | and to *t1*\* -1. (1)(4) |
341 +--------------------------------+-----------------------------------------------+
343 | | and to -*t* when ``t.days < 0``. (2) |
344 +--------------------------------+-----------------------------------------------+
348 +--------------------------------+-----------------------------------------------+
352 +--------------------------------+-----------------------------------------------+
367 -*timedelta.max* is not representable as a :class:`timedelta` object.
374 >>> timedelta(hours=-5)
375 datetime.timedelta(days=-1, seconds=68400)
377 -1 day, 19:00:00
380 The expression ``t2 - t3`` will always be equal to the expression ``t2 + (-t3)`` except
385 certain additions and subtractions with :class:`date` and :class:`.datetime`
417 TypeError: '>' not supported between instances of 'datetime.timedelta' and 'int'
459 >>> nine_years = ten_years - year
466 .. _datetime-date:
468 :class:`date` Objects
469 ---------------------
471 A :class:`date` object represents a date (year, month and day) in an idealized
478 .. class:: date(year, month, day)
492 .. classmethod:: date.today()
494 Return the current local date.
496 This is equivalent to ``date.fromtimestamp(time.time())``.
498 .. classmethod:: date.fromtimestamp(timestamp)
500 Return the local date corresponding to the POSIX timestamp, such as is
507 that on non-POSIX systems that include leap seconds in their notion of a
517 .. classmethod:: date.fromordinal(ordinal)
519 Return the date corresponding to the proleptic Gregorian ordinal, where
523 date.max.toordinal()``. For any date *d*,
524 ``date.fromordinal(d.toordinal()) == d``.
527 .. classmethod:: date.fromisoformat(date_string)
529 Return a :class:`date` corresponding to a *date_string* given in any valid
530 ISO 8601 format, except ordinal dates (e.g. ``YYYY-DDD``)::
532 >>> from datetime import date
533 >>> date.fromisoformat('2019-12-04')
534 datetime.date(2019, 12, 4)
535 >>> date.fromisoformat('20191204')
536 datetime.date(2019, 12, 4)
537 >>> date.fromisoformat('2021-W01-1')
538 datetime.date(2021, 1, 4)
542 Previously, this method only supported the format ``YYYY-MM-DD``.
544 .. classmethod:: date.fromisocalendar(year, week, day)
546 Return a :class:`date` corresponding to the ISO calendar date specified by
547 year, week and day. This is the inverse of the function :meth:`date.isocalendar`.
554 .. attribute:: date.min
556 The earliest representable date, ``date(MINYEAR, 1, 1)``.
559 .. attribute:: date.max
561 The latest representable date, ``date(MAXYEAR, 12, 31)``.
564 .. attribute:: date.resolution
566 The smallest possible difference between non-equal date objects,
570 Instance attributes (read-only):
572 .. attribute:: date.year
577 .. attribute:: date.month
582 .. attribute:: date.day
589 +-------------------------------+----------------------------------------------+
594 +-------------------------------+----------------------------------------------+
595 | ``date2 = date1 - timedelta`` | Computes *date2* such that ``date2 + |
597 +-------------------------------+----------------------------------------------+
598 | ``timedelta = date1 - date2`` | \(3) |
599 +-------------------------------+----------------------------------------------+
602 +-------------------------------+----------------------------------------------+
608 ``timedelta.days < 0``. Afterward ``date2 - date1 == timedelta.days``.
622 date2.toordinal()``. Date comparison raises :exc:`TypeError` if
623 the other comparand isn't also a :class:`date` object. However,
625 :meth:`timetuple` attribute. This hook gives other kinds of date objects a
626 chance at implementing mixed-type comparison. If not, when a :class:`date`
631 In Boolean contexts, all :class:`date` objects are considered to be true.
635 .. method:: date.replace(year=self.year, month=self.month, day=self.day)
637 Return a date with the same value, except for those parameters given new
642 >>> from datetime import date
643 >>> d = date(2002, 12, 31)
645 datetime.date(2002, 12, 26)
648 .. method:: date.timetuple()
652 The hours, minutes and seconds are 0, and the DST flag is -1.
656 time.struct_time((d.year, d.month, d.day, 0, 0, 0, d.weekday(), yday, -1))
658 where ``yday = d.toordinal() - date(d.year, 1, 1).toordinal() + 1``
662 .. method:: date.toordinal()
664 Return the proleptic Gregorian ordinal of the date, where January 1 of year 1
665 has ordinal 1. For any :class:`date` object *d*,
666 ``date.fromordinal(d.toordinal()) == d``.
669 .. method:: date.weekday()
672 For example, ``date(2002, 12, 4).weekday() == 2``, a Wednesday. See also
676 .. method:: date.isoweekday()
679 For example, ``date(2002, 12, 4).isoweekday() == 3``, a Wednesday. See also
683 .. method:: date.isocalendar()
698 >>> from datetime import date
699 >>> date(2003, 12, 29).isocalendar()
701 >>> date(2004, 1, 4).isocalendar()
707 .. method:: date.isoformat()
709 Return a string representing the date in ISO 8601 format, ``YYYY-MM-DD``::
711 >>> from datetime import date
712 >>> date(2002, 12, 4).isoformat()
713 '2002-12-04'
715 .. method:: date.__str__()
717 For a date *d*, ``str(d)`` is equivalent to ``d.isoformat()``.
720 .. method:: date.ctime()
722 Return a string representing the date::
724 >>> from datetime import date
725 >>> date(2002, 12, 4).ctime()
734 :meth:`date.ctime` does not invoke) conforms to the C standard.
737 .. method:: date.strftime(format)
739 Return a string representing the date, controlled by an explicit format string.
741 See also :ref:`strftime-strptime-behavior` and :meth:`date.isoformat`.
744 .. method:: date.__format__(format)
746 Same as :meth:`.date.strftime`. This makes it possible to specify a format
747 string for a :class:`.date` object in :ref:`formatted string
748 literals <f-strings>` and when using :meth:`str.format`.
749 See also :ref:`strftime-strptime-behavior` and :meth:`date.isoformat`.
751 Examples of Usage: :class:`date`
757 >>> from datetime import date
758 >>> today = date.today()
760 datetime.date(2007, 12, 5)
761 >>> today == date.fromtimestamp(time.time())
763 >>> my_birthday = date(today.year, 6, 24)
767 datetime.date(2008, 6, 24)
768 >>> time_to_birthday = abs(my_birthday - today)
772 More examples of working with :class:`date`:
776 >>> from datetime import date
777 >>> d = date.fromordinal(730920) # 730920th day after 1. 1. 0001
779 datetime.date(2002, 3, 11)
783 '2002-03-11'
805 -1
813 >>> # A date object is immutable; all operations produce a new object
815 datetime.date(2005, 3, 11)
818 .. _datetime-datetime:
821 --------------------------
824 from a :class:`date` object and a :class:`.time` object.
826 Like a :class:`date` object, :class:`.datetime` assumes the current Gregorian
869 Return the current local date and time.
872 or not specified, this is like :meth:`today`, but, if possible, supplies more
877 If *tz* is not ``None``, it must be an instance of a :class:`tzinfo` subclass,
878 and the current date and time are converted to *tz*’s time zone.
885 Return the current UTC date and time, with :attr:`.tzinfo` ``None``.
887 This is like :meth:`now`, but returns the current UTC date and time, as a naive
901 Return the local date and time corresponding to the POSIX timestamp, such as is
902 returned by :func:`time.time`. If optional argument *tz* is ``None`` or not
903 specified, the timestamp is converted to the platform's local date and time, and
906 If *tz* is not ``None``, it must be an instance of a :class:`tzinfo` subclass, and the
914 1970 through 2038. Note that on non-POSIX systems that include leap seconds in
975 .. classmethod:: datetime.combine(date, time, tzinfo=self.tzinfo)
977 Return a new :class:`.datetime` object whose date components are equal to the
978 given :class:`date` object's, and whose time components
985 ``d == datetime.combine(d.date(), d.time(), d.tzinfo)``. If date is a
1000 3. Ordinal dates are not currently supported.
1001 4. Fractional hours and minutes are not supported.
1006 >>> datetime.fromisoformat('2011-11-04')
1010 >>> datetime.fromisoformat('2011-11-04T00:05:23')
1012 >>> datetime.fromisoformat('2011-11-04T00:05:23Z')
1016 >>> datetime.fromisoformat('2011-W01-2T00:05:23.283')
1018 >>> datetime.fromisoformat('2011-11-04 00:05:23.283')
1020 >>> datetime.fromisoformat('2011-11-04 00:05:23.283+00:00')
1022 >>> datetime.fromisoformat('2011-11-04T00:05:23+04:00') # doctest: +NORMALIZE_WHITESPACE
1029 :meth:`date.isoformat()` or :meth:`datetime.isoformat()`.
1034 Return a :class:`.datetime` corresponding to the ISO calendar date specified
1035 by year, week and day. The non-date components of the datetime are populated
1046 If *format* does not contain microseconds or timezone information, this is equivalent to::
1052 time tuple. See also :ref:`strftime-strptime-behavior` and
1073 The smallest possible difference between non-equal :class:`.datetime` objects,
1077 Instance attributes (read-only):
1132 +---------------------------------------+--------------------------------+
1136 +---------------------------------------+--------------------------------+
1137 | ``datetime2 = datetime1 - timedelta`` | \(2) |
1138 +---------------------------------------+--------------------------------+
1139 | ``timedelta = datetime1 - datetime2`` | \(3) |
1140 +---------------------------------------+--------------------------------+
1143 +---------------------------------------+--------------------------------+
1149 datetime2 - datetime1 == timedelta after. :exc:`OverflowError` is raised if
1169 If both are aware and have different :attr:`~.datetime.tzinfo` attributes, ``a-b`` acts
1171 result is ``(a.replace(tzinfo=None) - a.utcoffset()) - (b.replace(tzinfo=None)
1172 - b.utcoffset())`` except that the implementation never overflows.
1198 :meth:`timetuple` attribute. This hook gives other kinds of date objects a
1199 chance at implementing mixed-type comparison. If not, when a :class:`.datetime`
1206 .. method:: datetime.date()
1208 Return :class:`date` object with same year, month and day.
1236 datetime with no conversion of date and time data.
1245 adjusting the date and time data so the result is the same UTC time as
1249 :meth:`utcoffset` and :meth:`dst` methods must not return ``None``. If *self*
1258 adjustment of date or time data is performed. Else the result is local
1260 ``astz = dt.astimezone(tz)``, ``astz - astz.utcoffset()`` will have
1261 the same date and time data as ``dt - dt.utcoffset()``.
1264 adjustment of date and time data, use ``dt.replace(tzinfo=tz)``. If you
1266 conversion of date and time data, use ``dt.replace(tzinfo=None)``.
1276 utc = (self - self.utcoffset()).replace(tzinfo=tz)
1295 The UTC offset is not restricted to a whole number of minutes.
1305 The DST offset is not restricted to a whole number of minutes.
1325 where ``yday = d.toordinal() - date(d.year, 1, 1).toordinal() + 1``
1329 ``None``, :attr:`tm_isdst` is set to ``-1``; else if :meth:`dst` returns a
1330 non-zero value, :attr:`tm_isdst` is set to ``1``; else :attr:`tm_isdst` is
1358 Return the proleptic Gregorian ordinal of the date. The same as
1359 ``self.date().toordinal()``.
1377 (dt - datetime(1970, 1, 1, tzinfo=timezone.utc)).total_seconds()
1389 application uses this convention and your system timezone is not
1397 timestamp = (dt - datetime(1970, 1, 1)) / timedelta(seconds=1)
1402 The same as ``self.date().weekday()``. See also :meth:`isoweekday`.
1408 The same as ``self.date().isoweekday()``. See also :meth:`weekday`,
1415 and ``weekday``. The same as ``self.date().isocalendar()``.
1420 Return a string representing the date and time in ISO 8601 format:
1422 - ``YYYY-MM-DDTHH:MM:SS.ffffff``, if :attr:`microsecond` is not 0
1423 - ``YYYY-MM-DDTHH:MM:SS``, if :attr:`microsecond` is 0
1425 If :meth:`utcoffset` does not return ``None``, a string is
1428 - ``YYYY-MM-DDTHH:MM:SS.ffffff+HH:MM[:SS[.ffffff]]``, if :attr:`microsecond`
1429 is not 0
1430 - ``YYYY-MM-DDTHH:MM:SS+HH:MM[:SS[.ffffff]]``, if :attr:`microsecond` is 0
1436 '2019-05-18T15:17:08.132263'
1438 '2019-05-18T15:17:00+00:00'
1440 The optional argument *sep* (default ``'T'``) is a one-character separator,
1441 placed between the date and time portions of the result. For example::
1445 ... """A time zone with an arbitrary, constant -06:39 offset."""
1447 ... return timedelta(hours=-6, minutes=-39)
1450 '2002-12-25 00:00:00-06:39'
1452 '2009-11-27T00:00:00.000100-06:39'
1458 - ``'auto'``: Same as ``'seconds'`` if :attr:`microsecond` is 0,
1460 - ``'hours'``: Include the :attr:`hour` in the two-digit ``HH`` format.
1461 - ``'minutes'``: Include :attr:`hour` and :attr:`minute` in ``HH:MM`` format.
1462 - ``'seconds'``: Include :attr:`hour`, :attr:`minute`, and :attr:`second`
1464 - ``'milliseconds'``: Include full time, but truncate fractional second
1466 - ``'microseconds'``: Include full time in ``HH:MM:SS.ffffff`` format.
1470 Excluded time components are truncated, not rounded.
1477 '2002-12-25T00:00'
1480 '2015-01-01T12:30:59.000000'
1494 Return a string representing the date and time::
1500 The output string will *not* include time zone information, regardless
1509 :meth:`datetime.ctime` does not invoke) conforms to the C standard.
1514 Return a string representing the date and time,
1516 See also :ref:`strftime-strptime-behavior` and :meth:`datetime.isoformat`.
1523 literals <f-strings>` and when using :meth:`str.format`.
1524 See also :ref:`strftime-strptime-behavior` and :meth:`datetime.isoformat`.
1534 >>> from datetime import datetime, date, time, timezone
1537 >>> d = date(2005, 7, 14)
1566 -1 # dst - method tzinfo.dst() returned None
1568 >>> # Date in ISO format
1597 # An ambiguous ("imaginary") half-hour range representing
1607 if not isinstance(dt, datetime):
1609 if dt.tzinfo is not self:
1610 raise ValueError("dt.tzinfo is not self")
1622 # Kabul does not observe daylight saving time.
1653 .. _datetime-time:
1656 ----------------------
1691 The smallest possible difference between non-equal :class:`.time` objects,
1693 :class:`.time` objects is not supported.
1696 Instance attributes (read-only):
1745 to stop mixed-type comparisons from falling back to the default comparison by
1759 error-prone and has been removed in Python 3.5. See :issue:`13936` for full
1772 a date and a time, is not required.
1775 4. Fractional hours and minutes are not supported.
1822 - ``HH:MM:SS.ffffff``, if :attr:`microsecond` is not 0
1823 - ``HH:MM:SS``, if :attr:`microsecond` is 0
1824 - ``HH:MM:SS.ffffff+HH:MM[:SS[.ffffff]]``, if :meth:`utcoffset` does not return ``None``
1825- ``HH:MM:SS+HH:MM[:SS[.ffffff]]``, if :attr:`microsecond` is 0 and :meth:`utcoffset` does not ret…
1831 - ``'auto'``: Same as ``'seconds'`` if :attr:`microsecond` is 0,
1833 - ``'hours'``: Include the :attr:`hour` in the two-digit ``HH`` format.
1834 - ``'minutes'``: Include :attr:`hour` and :attr:`minute` in ``HH:MM`` format.
1835 - ``'seconds'``: Include :attr:`hour`, :attr:`minute`, and :attr:`second`
1837 - ``'milliseconds'``: Include full time, but truncate fractional second
1839 - ``'microseconds'``: Include full time in ``HH:MM:SS.ffffff`` format.
1843 Excluded time components are truncated, not rounded.
1870 string. See also :ref:`strftime-strptime-behavior` and :meth:`time.isoformat`.
1877 literals <f-strings>` and when using :meth:`str.format`.
1878 See also :ref:`strftime-strptime-behavior` and :meth:`time.isoformat`.
1888 The UTC offset is not restricted to a whole number of minutes.
1898 The DST offset is not restricted to a whole number of minutes.
1937 .. _datetime-tzinfo:
1940 -----------------------
1944 This is an abstract base class, meaning that this class should not be
1952 zone, and DST offset, all relative to a date or time object passed to them.
1963 pickled but possibly not unpickled again. This is a technical requirement that
1980 strictly between ``-timedelta(hours=24)`` and ``timedelta(hours=24)``
1984 return CONSTANT # fixed-offset class
1985 return CONSTANT + self.dst(dt) # daylight-aware class
1987 If :meth:`utcoffset` does not return ``None``, :meth:`dst` should not return
1994 The UTC offset is not restricted to a whole number of minutes.
2003 Return ``timedelta(0)`` if DST is not in effect.
2016 ``tz.utcoffset(dt) - tz.dst(dt)``
2020 zone's "standard offset", which should not depend on the date or the time, but
2030 # a fixed-offset class: doesn't account for DST
2048 The DST offset is not restricted to a whole number of minutes.
2056 "GMT", "UTC", "-500", "-5:00", "EDT", "US/Eastern", "America/New York" are all
2082 time, and not need worry about objects in other timezones.
2091 date and time data are to be viewed as expressing a UTC time. The purpose
2092 of :meth:`fromutc` is to adjust the date and time data, returning an
2097 fixed-offset time zones, and time zones accounting for both standard and
2100 implementation may not handle correctly in all cases is one where the standard
2101 offset (from UTC) depends on the specific date and time passed, which can happen
2103 :meth:`fromutc` may not produce the result you want if the result is one of the
2110 # raise ValueError error if dt.tzinfo is not self
2114 delta = dtoff - dtdst # this is self's standard offset
2132 points. For concreteness, consider US Eastern (UTC -0500), where EDT begins the
2188 Applications that can't bear wall-time ambiguities should explicitly check the
2191 or any other fixed-offset :class:`tzinfo` subclass (such as a class representing
2192 only EST (fixed offset -5 hours), or only EDT (fixed offset -4 hours)).
2204 `IANA timezone database <https://www.iana.org/time-zones>`_
2209 daylight-saving rules.
2212 .. _datetime-timezone:
2215 --------------------------
2230 be strictly between ``-timedelta(hours=24)`` and
2239 The UTC offset is not restricted to a whole number of minutes.
2251 The UTC offset is not restricted to a whole number of minutes.
2258 If *name* is not provided in the constructor, the name returned by
2265 Name generated from ``offset=timedelta(0)`` is now plain ``'UTC'``, not
2288 .. _strftime-strptime-behavior:
2291 ----------------------------------------------
2293 :class:`date`, :class:`.datetime`, and :class:`.time` objects all support a
2298 :class:`.datetime` object from a string representing a date and time and a
2301 The table below provides a high-level comparison of :meth:`strftime`
2304----------------+--------------------------------------------------------+------------------------…
2308----------------+--------------------------------------------------------+------------------------…
2310----------------+--------------------------------------------------------+------------------------…
2311 | Method of | :class:`date`; :class:`.datetime`; :class:`.time` | :class:`.datetime` …
2312----------------+--------------------------------------------------------+------------------------…
2314----------------+--------------------------------------------------------+------------------------…
2331 +-----------+--------------------------------+------------------------+-------+
2338 +-----------+--------------------------------+------------------------+-------+
2343 +-----------+--------------------------------+------------------------+-------+
2347 +-----------+--------------------------------+------------------------+-------+
2349 | | zero-padded decimal number. | | |
2350 +-----------+--------------------------------+------------------------+-------+
2355 +-----------+--------------------------------+------------------------+-------+
2360 +-----------+--------------------------------+------------------------+-------+
2361 | ``%m`` | Month as a zero-padded | 01, 02, ..., 12 | \(9) |
2363 +-----------+--------------------------------+------------------------+-------+
2365 | | zero-padded decimal number. | | |
2366 +-----------+--------------------------------+------------------------+-------+
2369 +-----------+--------------------------------+------------------------+-------+
2370 | ``%H`` | Hour (24-hour clock) as a | 00, 01, ..., 23 | \(9) |
2371 | | zero-padded decimal number. | | |
2372 +-----------+--------------------------------+------------------------+-------+
2373 | ``%I`` | Hour (12-hour clock) as a | 01, 02, ..., 12 | \(9) |
2374 | | zero-padded decimal number. | | |
2375 +-----------+--------------------------------+------------------------+-------+
2378 +-----------+--------------------------------+------------------------+-------+
2379 | ``%M`` | Minute as a zero-padded | 00, 01, ..., 59 | \(9) |
2381 +-----------+--------------------------------+------------------------+-------+
2382 | ``%S`` | Second as a zero-padded | 00, 01, ..., 59 | \(4), |
2384 +-----------+--------------------------------+------------------------+-------+
2386 | | number, zero-padded to 6 | 999999 | |
2388 +-----------+--------------------------------+------------------------+-------+
2390 | | ``±HHMM[SS[.ffffff]]`` (empty | -0400, +1030, | |
2392 | | naive). | -030712.345216 | |
2393 +-----------+--------------------------------+------------------------+-------+
2396 +-----------+--------------------------------+------------------------+-------+
2398 | | zero-padded decimal number. | | |
2399 +-----------+--------------------------------+------------------------+-------+
2402 | | the week) as a zero-padded | | |
2407 +-----------+--------------------------------+------------------------+-------+
2410 | | the week) as a zero-padded | | |
2415 +-----------+--------------------------------+------------------------+-------+
2416 | ``%c`` | Locale's appropriate date and || Tue Aug 16 21:30:00 | \(1) |
2420 +-----------+--------------------------------+------------------------+-------+
2421 | ``%x`` | Locale's appropriate date || 08/16/88 (None); | \(1) |
2424 +-----------+--------------------------------+------------------------+-------+
2427 +-----------+--------------------------------+------------------------+-------+
2429 +-----------+--------------------------------+------------------------+-------+
2431 Several additional directives not required by the C89 standard are included for
2432 convenience. These parameters all correspond to ISO 8601 date values.
2434 +-----------+--------------------------------+------------------------+-------+
2441 +-----------+--------------------------------+------------------------+-------+
2444 +-----------+--------------------------------+------------------------+-------+
2450 +-----------+--------------------------------+------------------------+-------+
2452 These may not be available on all platforms when used with the :meth:`strftime`
2453 method. The ISO 8601 year and ISO 8601 week directives are not interchangeable
2470 ``time.strftime(fmt, d.timetuple())`` although not all objects support a
2474 ``1900-01-01T00:00:00.000``: any components not specified in the format string
2481 except when the format includes sub-second components or timezone offset
2485 For :class:`.time` objects, the format codes for year, month, and day should not
2489 For :class:`date` objects, the format codes for hours, minutes, seconds, and
2490 microseconds should not be used, as :class:`date` objects have no such
2495 platform-dependent. On some platforms such code points are preserved intact in
2505 contain non-ASCII characters.
2509 years < 1000 must be zero-filled to 4-digit width.
2524 Unlike the :mod:`time` module, the :mod:`datetime` module does not support
2542 ``±HHMM[SS[.ffffff]]``, where ``HH`` is a 2-digit string giving the number
2543 of UTC offset hours, ``MM`` is a 2-digit string giving the number of UTC
2544 offset minutes, ``SS`` is a 2-digit string giving the number of UTC offset
2545 seconds and ``ffffff`` is a 6-digit string giving the number of UTC
2549 :meth:`utcoffset` returns ``timedelta(hours=-3, minutes=-30)``, ``%z`` is
2550 replaced with the string ``'-0330'``.
2553 The UTC offset is not restricted to a whole number of minutes.
2570 2. the hard-coded values ``UTC`` and ``GMT``
2573 valid values, but probably not ``EST``. It will raise ``ValueError`` for
2589 :meth:`strptime` format string. Also note that ``%G`` and ``%Y`` are not
2611 .. [#] Passing ``datetime.strptime('Feb 29', '%b %d')`` will fail since ``1900`` is not a leap year.