PEP 410: complete datetime, timedelta and boolean flag sections

This commit is contained in:
Victor Stinner 2012-02-14 13:54:59 +01:00
parent 7bed2dcc53
commit 6407397109
1 changed files with 13 additions and 5 deletions

View File

@ -135,9 +135,10 @@ without timezone and a datetime with a timezone cannot be compared.
datetime.datetime has ordering issues with daylight saving time (DST) in the
duplicate hour of switching from DST to normal time.
datetime.datetime is not as well integrated than Epoch timestamps, some
functions don't accept this type as input. For example, os.utime() expects a
tuple of Epoch timestamps.
datetime.datetime is not as well integrated than Epoch timestamps: there is no
datetime.datetime.totimestamp() function. Most functions expecting tiemstamps
don't support datime.datetime. For example, os.utime() expects a tuple of Epoch
timestamps.
datetime.timedelta
------------------
@ -146,8 +147,11 @@ As datetime.datetime, datetime.timedelta only supports microsecond resolution,
but can be enhanced to support nanosecond.
datetime.timedelta is not as well integrated than Epoch timestamps, some
functions don't accept this type as input. For example, os.utime() expects a
tuple of Epoch timestamps.
functions don't accept this type as input. Converting a timedelta object to a
float (number of seconds) requires to call an explicit method,
timedelta.toseconds(). Supporting timedelta would need to change every
functions getting timestamps, whereas all functions supporting float already
accept Decimal because Decimal can be casted to float.
.. _tuple-integers:
@ -255,6 +259,9 @@ Add a boolean argument
Because we only need one new type, decimal.Decimal, a simple boolean flag
can be added. For example, time.time(decimal=True) or time.time(hires=True).
Such flag would require to do an hidden import which is considered as a bad
practice.
The boolean argument API was rejected because it is not "pythonic". Changing
the return type with a parameter value is preferred over a boolean parameter (a
flag).
@ -279,6 +286,7 @@ Links
* `Issue #11457: os.stat(): add new fields to get timestamps as Decimal objects with nanosecond resolution <http://bugs.python.org/issue11457>`_
* `Issue #13882: Add format argument for time.time(), time.clock(), ... to get a timestamp as a Decimal object <http://bugs.python.org/issue13882>`_
* `[Python-Dev] Store timestamps as decimal.Decimal objects <http://mail.python.org/pipermail/python-dev/2012-January/116025.html>`_
* `Issue #7652: Merge C version of decimal into py3k <http://bugs.python.org/issue7652>`_ (cdecimal)
Copyright