Message54315
Logged In: YES
user_id=31435
Sorry, I really don't see a point to this. The claim that slicing
doesn't work is unbelievable on two counts:
1. If someone has a datetime object D, and wants, e.g.,
the year, they don't do str(D), try to slice out the year
digits, then convert them to an int(!) -- they just do
D.year. Same for the other members (including
D.microsecond).
2. Slicing works anyway. For example, str(D)[:4] gets
the year digits regardless of D.microsecond. str(D)[17:]
gets the seconds likewise, and float(str(D)[17:]) gets
the number of seconds as a float regardless of whether
D.microsecond is 0.
If you want D without microseconds, the intended way to do
it is one of:
a) Don't set microseconds if you don't want microseconds;
or, if you're stuck with unwanted microseconds,
b) Use D.replace(microsecond=0) to get a copy of D
but with microsecond forced to 0.
The current behavior is by design, and documented, so won't
be changed regardless.
I'm somewhere between -1 and -0 on complicating signatures
to give a shortcut for something that's rarely needed and
easy to get anyway. |
|
Date |
User |
Action |
Args |
2007-08-23 16:08:34 | admin | link | issue1074462 messages |
2007-08-23 16:08:34 | admin | create | |
|