[issue2736] datetime needs an "epoch" method
Alexander Belopolsky
report at bugs.python.org
Fri May 21 18:06:08 CEST 2010
Alexander Belopolsky <alexander.belopolsky at gmail.com> added the comment:
On Fri, May 21, 2010 at 7:37 AM, Antoine Pitrou <report at bugs.python.org> wrote:
..
> I agree with Victor that the APIs need improving, even if it involves providing obvious replacements of obscure one-liners.
While I agree that the datetime API can be improved, I don't think
Victor's proposal does that. The advantage of an obscure one-liner is
that it is obvious what it does, particularly for someone with a
C/UNIX background. dt.totimestamp() may be easier to write, but it is
entirely non-obvious what it will return. One would expect that
dt.totimestamp() is the inverse of datetime.fromtimestamp(timestamp),
but in timezones with daylight savings adjustments, but such inverse
may not always exist. (01:59AM may be followed by 02:00 AM or by
01:00 AM. so on changeover days datetime(y, m, d, 1, 30).totimestamp()
is either ambiguous or undefined.) As I suggested in my previous
comment, this problem can be resolved, but we are not there yet.
> As an occasional user of datetime and time modules, I have too often wanted to curse those limited, awkwardly inconsistent APIs.
Yes, it would be ideal if a user of datetime module would not need to
reach to other modules for date/time calculations. See also
<http://bugs.python.org/issue6280>. Do you have other examples of
this sort?
----------
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue2736>
_______________________________________
More information about the Python-bugs-list
mailing list