[issue1436346] yday in datetime module

2010-05-23 Thread Alexander Belopolsky

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

Attaching a documentation patch.

--
Added file: http://bugs.python.org/file17446/issue1436346-doc.diff

___
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



[issue1436346] yday in datetime module

2010-05-23 Thread Alexander Belopolsky

Changes by Alexander Belopolsky belopol...@users.sourceforge.net:


--
assignee: belopolsky - 
components: +Documentation
keywords: +needs review
versions: +Python 2.7

___
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



[issue1436346] yday in datetime module

2010-05-23 Thread Georg Brandl

Georg Brandl ge...@python.org added the comment:

Committed in r81489.  Thanks!

--
resolution:  - fixed
status: open - closed

___
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



[issue1436346] yday in datetime module

2010-05-22 Thread Georg Brandl

Georg Brandl ge...@python.org added the comment:

Care to suggest a patch?

--

___
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



[issue1436346] yday in datetime module

2010-05-21 Thread Alexander Belopolsky

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



[issue1436346] yday in datetime module

2010-05-21 Thread Alexander Belopolsky

Changes by Alexander Belopolsky belopol...@users.sourceforge.net:


--
nosy: +georg.brandl

___
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



[issue1436346] yday in datetime module

2010-05-20 Thread Antoine Pitrou

Changes by Antoine Pitrou pit...@free.fr:


--
nosy: +belopolsky, mark.dickinson
versions:  -Python 2.7

___
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



[issue1436346] yday in datetime module

2010-05-20 Thread Alexander Belopolsky

Changes by Alexander Belopolsky belopol...@users.sourceforge.net:


--
assignee:  - belopolsky

___
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



[issue1436346] yday in datetime module

2010-05-20 Thread Alexander Belopolsky

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

I think this should be rejected.  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.  The later is only slightly less readable than the 
proposed t.yday().

For the other half of the proposal, Marc-Andre's mxDate code translates into 
only slightly more complicated stdlib datetime code:

def date_fromyday(year, yday):
   return date(year, 1, 1) + timedelta(yday - 1)

--

___
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



[issue1436346] yday in datetime module

2010-05-20 Thread Antoine Pitrou

Antoine Pitrou pit...@free.fr added the comment:

 I think this should be rejected.  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 datetime / time jungle is difficult to navigate through, and I think
for most people it is not obvious that the answer to their needs is to
look at one of the attributes of the timetuple() result...

--

___
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



[issue1436346] yday in datetime module

2009-08-05 Thread Antoine Pitrou

Antoine Pitrou pit...@free.fr added the comment:

Some comments:
- since there is already a weekday() method, the new method should be
called yearday() rather than yday()
- ditto for fromyday(): fromyearday() would be better
- Modules/datetimemodule.c should only be indented with tabs, but your
patch indents it with spaces in some places
- the algorithm in date_fromyday() looks suboptimal: if you repeatedly
call days_in_month(), you shouldn't have to call days_before_month() at
the end, you can compute it by yourself

I haven't tested the patch yet.

Marc-André, do you have any take on the principle of this?

--
nosy: +lemburg
stage: test needed - patch review

___
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



[issue1436346] yday in datetime module

2009-08-05 Thread Marc-Andre Lemburg

Marc-Andre Lemburg m...@egenix.com added the comment:

Antoine Pitrou wrote:
 
 Antoine Pitrou pit...@free.fr added the comment:
 
 Some comments:
 - since there is already a weekday() method, the new method should be
 called yearday() rather than yday()
 - ditto for fromyday(): fromyearday() would be better
 - Modules/datetimemodule.c should only be indented with tabs, but your
 patch indents it with spaces in some places
 - the algorithm in date_fromyday() looks suboptimal: if you repeatedly
 call days_in_month(), you shouldn't have to call days_before_month() at
 the end, you can compute it by yourself
 
 I haven't tested the patch yet.
 
 Marc-André, do you have any take on the principle of this?

mxDateTime uses attributes for such things, ie. .day_of_week,
.day_of_year, .days_in_month. No idea, why the datetime module
chose to implement access to this static information as method.

I've never had a request for a way to construct a date by
giving the year and day of the year - probably because it's
just too easy to do by hand:

217
 Date(2009, 1, 1) + (217 - 1)
mx.DateTime.DateTime object for '2009-08-05 00:00:00.00' at 2b5320c262f0

--

___
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



[issue1436346] yday in datetime module

2009-08-05 Thread Marc-Andre Lemburg

Marc-Andre Lemburg m...@egenix.com added the comment:

Hmm, looks like there's a bug in roundup's email interface... the code
snippet should have read:

 from mx.DateTime import *
 today().day_of_year
217
 Date(2009, 1, 1) + (217 - 1)
mx.DateTime.DateTime object for '2009-08-05 00:00:00.00' at 2b5320c262f0

--

___
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



[issue1436346] yday in datetime module

2009-07-24 Thread Antoine Pitrou

Changes by Antoine Pitrou pit...@free.fr:


--
nosy: +pitrou
versions: +Python 3.2 -Python 3.1

___
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



[issue1436346] yday in datetime module

2009-07-19 Thread Jubaraj Borgohain

Jubaraj Borgohain jubarajborgoh...@gmail.com added the comment:

I have completed the following two new features for the datetime module
(the changes are attached as a patch):
a. Added a method yday()
b. Added date.fromyday(year,yday), which returns a date object.
The other features requested are already available.
The tests for these two new features have also been added to
test_datetimemodule.py.
The patch has been only tested on trunk.(Python 2.7)

--
keywords: +patch
nosy: +jborgohain
Added file: http://bugs.python.org/file14525/issue1436346.diff

___
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



[issue1436346] yday in datetime module

2009-03-20 Thread Daniel Diniz

Changes by Daniel Diniz aja...@gmail.com:


--
stage:  - test needed
versions: +Python 2.7, Python 3.1

___
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