<div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Mar 5, 2014 at 5:53 PM, Tim Peters <span dir="ltr"><<a href="mailto:tim.peters@gmail.com" target="_blank">tim.peters@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div id=":57g" class="" style="overflow:hidden">That's there because `<span class="">utcoffset</span>()` is defined to return minutes. </div>
</blockquote><div><br></div><div>It returns either minutes <u>or a timedelta</u>:</div><div><br></div></div></div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div class="gmail_extra"><div class="gmail_quote">
<div><dt id="datetime.datetime.utcoffset" style="color:rgb(0,0,0);font-family:sans-serif"><tt class="" style="background-color:transparent;padding:0px 1px">datetime.</tt><tt class="" style="background-color:transparent;padding:0px 1px;font-weight:bold">utcoffset</tt><big>(</big><big>)</big><a class="" href="http://docs.python.org/2/library/datetime.html#datetime.datetime.utcoffset" title="Permalink to this definition" style="color:rgb(198,15,15);text-decoration:none;padding:0px 4px">¶</a></dt>
</div></div></div></blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div class="gmail_extra"><div class="gmail_quote"><div>
<div><span style="color:rgb(0,0,0);font-family:sans-serif;line-height:20.799999237060547px;text-align:justify">If</span><span style="color:rgb(0,0,0);font-family:sans-serif;line-height:20.799999237060547px;text-align:justify"> </span><a class="" href="http://docs.python.org/2/library/datetime.html#datetime.tzinfo" title="datetime.tzinfo" style="font-family:sans-serif;line-height:20.799999237060547px;text-align:justify;color:rgb(53,95,124);text-decoration:none"><tt class="" style="background-color:transparent;padding:0px 1px;font-weight:bold"><span class="">tzinfo</span></tt></a><span style="color:rgb(0,0,0);font-family:sans-serif;line-height:20.799999237060547px;text-align:justify"> </span><span style="color:rgb(0,0,0);font-family:sans-serif;line-height:20.799999237060547px;text-align:justify">is</span><span style="color:rgb(0,0,0);font-family:sans-serif;line-height:20.799999237060547px;text-align:justify"> </span><tt class="" style="color:rgb(0,0,0);line-height:20.799999237060547px;text-align:justify;background-color:transparent;padding:0px 1px;font-weight:bold"><span class="">None</span></tt><span style="color:rgb(0,0,0);font-family:sans-serif;line-height:20.799999237060547px;text-align:justify">, returns</span><span style="color:rgb(0,0,0);font-family:sans-serif;line-height:20.799999237060547px;text-align:justify"> </span><tt class="" style="color:rgb(0,0,0);line-height:20.799999237060547px;text-align:justify;background-color:transparent;padding:0px 1px;font-weight:bold"><span class="">None</span></tt><span style="color:rgb(0,0,0);font-family:sans-serif;line-height:20.799999237060547px;text-align:justify">, else returns</span><span style="color:rgb(0,0,0);font-family:sans-serif;line-height:20.799999237060547px;text-align:justify"> </span><tt class="" style="color:rgb(0,0,0);line-height:20.799999237060547px;text-align:justify;background-color:rgb(236,240,243);padding:0px 1px"><span class="">self.tzinfo.utcoffset(self)</span></tt><span style="color:rgb(0,0,0);font-family:sans-serif;line-height:20.799999237060547px;text-align:justify">, and raises an exception if the latter doesn’t return</span><span style="color:rgb(0,0,0);font-family:sans-serif;line-height:20.799999237060547px;text-align:justify"> </span><tt class="" style="color:rgb(0,0,0);line-height:20.799999237060547px;text-align:justify;background-color:transparent;padding:0px 1px;font-weight:bold"><span class="">None</span></tt><span style="color:rgb(0,0,0);font-family:sans-serif;line-height:20.799999237060547px;text-align:justify">, or a</span><span style="color:rgb(0,0,0);font-family:sans-serif;line-height:20.799999237060547px;text-align:justify"> </span><a class="" href="http://docs.python.org/2/library/datetime.html#datetime.timedelta" title="datetime.timedelta" style="font-family:sans-serif;line-height:20.799999237060547px;text-align:justify;color:rgb(53,95,124);text-decoration:none"><tt class="" style="background-color:transparent;padding:0px 1px;font-weight:bold"><span class="">timedelta</span></tt></a><span style="color:rgb(0,0,0);font-family:sans-serif;line-height:20.799999237060547px;text-align:justify"> </span><span style="color:rgb(0,0,0);font-family:sans-serif;line-height:20.799999237060547px;text-align:justify">object representing a whole number of minutes with magnitude less than one day.</span></div>
</div></div></div></blockquote></blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div class="gmail_extra"><div class="gmail_quote"><div><div><span style="color:rgb(0,0,0);font-family:sans-serif;line-height:20.799999237060547px;text-align:justify"><br>
</span></div></div></div></div><div class="gmail_extra"><div class="gmail_quote"><div><div><dt id="datetime.tzinfo.utcoffset" style="color:rgb(0,0,0);font-family:sans-serif"><tt class="" style="background-color:transparent;padding:0px 1px">tzinfo.</tt><tt class="" style="background-color:transparent;padding:0px 1px;font-weight:bold">utcoffset</tt><big>(</big><em>self</em>, <em>dt</em><big>)</big></dt>
</div></div></div></div><div class="gmail_extra"><div class="gmail_quote"><div><div><dd style="margin-top:3px;margin-bottom:10px;margin-left:30px;text-align:justify;line-height:20.799999237060547px;color:rgb(0,0,0);font-family:sans-serif">
<p style="margin-top:0px">Return offset of local time from UTC, in minutes east of UTC. If local time is west of UTC, this should be negative. Note that this is intended to be the total offset from UTC; for example, if a<a class="" href="http://docs.python.org/2/library/datetime.html#datetime.tzinfo" title="datetime.tzinfo" style="color:rgb(53,95,124);text-decoration:none"><tt class="" style="background-color:transparent;padding:0px 1px;font-weight:bold"><span class="">tzinfo</span></tt></a> object represents both time zone and DST adjustments, <a class="" href="http://docs.python.org/2/library/datetime.html#datetime.tzinfo.utcoffset" title="datetime.tzinfo.utcoffset" style="color:rgb(53,95,124);text-decoration:none"><tt class="" style="background-color:transparent;padding:0px 1px;font-weight:bold"><span class="">utcoffset()</span></tt></a> should return their sum. If the UTC offset isn’t known, return <tt class="" style="background-color:transparent;padding:0px 1px;font-weight:bold"><span class="">None</span></tt>. Else the value returned must be a <a class="" href="http://docs.python.org/2/library/datetime.html#datetime.timedelta" title="datetime.timedelta" style="color:rgb(53,95,124);text-decoration:none"><tt class="" style="background-color:transparent;padding:0px 1px;font-weight:bold"><span class="">timedelta</span></tt></a>object specifying a whole number of minutes in the range -1439 to 1439 inclusive (1440 = 24*60; the magnitude of the offset must be less than one day).<span style="font-family:arial;line-height:normal;color:rgb(34,34,34)"> </span></p>
</dd></div></div></div></div><div class="gmail_extra"><div class="gmail_quote"><div><br></div></div></div></blockquote><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div id=":57g" class="" style="overflow:hidden">A<br>
rule is needed to specify how the naive time object and `<span class="">utcoffset</span>()`<br>
interact to define the result.</div></blockquote><div><br></div><div>Not sure why you attach 'naive' to time. Time objects carry units with them, unlike integers. I would say 'naive time value' in reference to an integer.</div>
<div><br></div><div>Combining a time and an integer can be done by converting the time to minutes (which is a bit confusing since in most contexts in this class, minutes values are integers) or it can be done by interpreting the integer utcoffset result as minutes (as it is documented).</div>
<div><br></div><div> <br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div id=":57g" class="" style="overflow:hidden">
<div class="">> Perhaps a reasonable improvement would be to change this to:<br></div><div class="">
><br>
> a time object is considered to be true unless it represents exactly <span class="" tabindex="0"><span class="">midnight</span></span><br>
> local time, </div></div></blockquote><div><br></div><div>The above part is the key part of my suggested improvement. Reading the current documentation, the fact that it means midnight local time is falsey is not obvious. </div>
<div><br></div></div><br clear="all"><div><div dir="ltr"><font face="arial, helvetica, sans-serif">--- Bruce<br></font><div><div><font face="arial, helvetica, sans-serif">Learn how hackers think: <a href="http://j.mp/gruyere-security" target="_blank">http://j.mp/gruyere-security</a></font></div>
</div><div><div style="font-family:arial;font-size:small"><a href="https://www.linkedin.com/in/bruceleban" style="color:rgb(17,85,204)" target="_blank">https://www.linkedin.com/in/bruceleban</a><br></div></div><div><br></div>
</div></div>
</div></div>