<div class="gmail_quote">On 1 June 2010 13:17, Guido van Rossum <span dir="ltr"><<a href="mailto:guido@python.org">guido@python.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

<div><div></div><div class="h5">On Tue, Jun 1, 2010 at 8:23 AM, Alexander Belopolsky<br>
<<a href="mailto:alexander.belopolsky@gmail.com">alexander.belopolsky@gmail.com</a>> wrote:<br>
> On Tue, Jun 1, 2010 at 10:41 AM, Mark Dickinson <<a href="mailto:dickinsm@gmail.com">dickinsm@gmail.com</a>> wrote:<br>
> ..<br>
>> As per the POSIX standard (IIUC), [datetime(1985, 6, 30, 23, 59, 60)] would be<br>
>> immediately converted<br>
>> to datetime.datetime(1985, 7, 1, 0, 0, 0) internally.  So the datetime<br>
>> object itself wouldn't support leap seconds, and would continue to use<br>
>> POSIX time;  only the constructor would support leap seconds.<br>
>><br>
><br>
> It is my understanding that POSIX mandates that mktime() function<br>
> normalizes the tm structure and therefore converts (1985, 6, 30, 23,<br>
> 59, 60, ...) to (1985, 7, 1, 0, 0, 0, ...).  It is not quite accurate<br>
> to say that tm structure is converted "immediately".  It is perfectly<br>
> legal to pass around non-normalized tm structures and have for example<br>
> utc2gps() function that would produce different values for Y-M-D<br>
> 23:59:60 and T-M-[D+1] 00:00:00.<br>
><br>
> I would prefer a similar behavior for datetime constructor:<br>
><br>
>>>> datetime(1985, 6, 30, 23, 59, 60).second<br>
> 60<br>
>>>> datetime(1985, 6, 30, 23, 59, 60).timetuple()<br>
> (1985, 6, 30, 23, 59, 60, ...)<br>
><br>
> but<br>
>>>> datetime(1985, 6, 30, 23, 59, 60) - datetime(1985, 7, 1, 0, 0, 0)<br>
> datetime.timedelta(0)<br>
<br>
</div></div>I expect this will cause a lot of subtle issues. E.g. What should<br>
comparison of an unnormalized datetime value to an equivalent<br>
normalized datetime value yield? How far will you go? Is<br>
datetime.datetime(2010, 6, 1, 36, 0, 0) a way of spelling<br>
datetime.datetime(2010, 6, 2, 12, 0 0) ? How do you force<br>
normalization? Won't it break apps if the .seconds attribute can be<br>
out of range or if normalization calls need to be inserted?<br>
<br>
The datetime module was written with "commercial" and everyday use in<br>
mind. In such use, there is no need to carry leap seconds around.<br>
<div><div></div><div class="h5"><br></div></div></blockquote><div><br></div><div>If this is really a design choice, then I guess my suggestions about</div><div>date+time literals and a unique/"official" date+time interpretation as</div>

<div>number really aren't good ideas. (Although I can't see why a</div><div>precise/scientific approach wouldn't be better than a commercial</div><div>one, as commercial applications often rely on precise standards.)</div>

<div><br></div><div>But I still don't understand why datetime.datetime.toordinal returns</div><div>an int that truncates time information. Is this deliberate?</div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

<div><div class="h5">
--<br>
--Guido van Rossum (<a href="http://python.org/~guido" target="_blank">python.org/~guido</a>)<br>
</div></div></blockquote></div><br clear="all"><br>-- Marcos --<br>