Alexander Belopolsky <belopol...@users.sourceforge.net> added the comment:

On Thu, May 20, 2010 at 7:27 PM, Antoine Pitrou <rep...@bugs.python.org> wrote:
>
>> .. The OP's premise was that
>> t.timetuple()[7] was unreadable, but in the modern python, the same
>> can be written as t.timetuple().tm_yday.
>
> Could I suggest such example be added to the documentation, though?

The documentation for timetuple method [1, 2] already contains a
recipe for computing yday which is more efficient than
t.timetuple().tm_yday:

 yday = d.toordinal() - date(d.year, 1, 1).toordinal() + 1

Maybe it can be improved by making it discoverable in searches for yday:

"""
... is equivalent to time.struct_time((d.year, d.month, d.day, d.hour,
d.minute, d.second, d.weekday(), yday, dst)), where yday =
d.toordinal() - date(d.year, 1, 1).toordinal() + 1 is the day number
of the year starting from 1 for January 1st.
"""

[1] http://docs.python.org/py3k/library/datetime.html#datetime.date.timetuple
[2] 
http://docs.python.org/py3k/library/datetime.html#datetime.datetime.timetuple

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue1436346>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to