YADTR (Yet Another DateTime Rant)

Marko Rauhamaa marko at pacujo.net
Wed Mar 26 15:43:04 CET 2014


Antoon Pardon <antoon.pardon at rece.vub.ac.be>:

> On 26-03-14 01:58, Roy Smith wrote:
>> 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".
> There is a difference between how people say things and what is useful.

There is a standard timedelta representation:

  <URL: http://www.schemacentral.com/sc/xsd/t-xsd_duration.html>

  <URL: http://en.wikipedia.org/wiki/ISO_8601#Durations>

If timedelta() were created today, it really should use that one because
it is the only standard one, even though few people would use that in a
human interface.

Thus:

   -P1DT22H25M26.295993S


Marko



More information about the Python-list mailing list