YADTR (Yet Another DateTime Rant)

Ethan Furman ethan at stoneleaf.us
Wed Mar 26 19:33:50 EDT 2014


On 03/26/2014 04:25 PM, Dennis Lee Bieber wrote:
> On Tue, 25 Mar 2014 20:58:27 -0400, Roy Smith <roy at panix.com> declaimed the
> following:
>
>> One of my roles on this newsgroup is to periodically whine about
>> stupidities in the Python datetime module.  This is one of those times.
>>
>> I have some code which computes how long ago the sun set.  Being a nice
>> pythonista, I'm using a timedelta to represent this value.  It would be
>> difficult to imagine a less useful default way to print a timedelta:
>>
>> previous sunset: -1 day, 22:25:26.295993
>>
>> The idea of str() is that it's supposed to return a human-friendly
>> representation of a value.  Humans do not say things like, "The sun set
>> 1 day ago plus 22 hours and 25 minutes".
>
> 	Makes sense to me -- the key being time DELTA... IE, a difference from
> some (unspecified) instance in time...
>
> 	If you want an instance of time, you need to add some known instance
> and the delta value.

Making sense is not the same as user friendly...

   "Hey, when did Bob get here?"

   "About 15 minutes ago."

vs

   "About an hour ago, plus 45 minutes."

--
~Ethan~



More information about the Python-list mailing list