date diff calc

David Fraser davidf at sjsoft.com
Thu Dec 2 04:59:23 EST 2004


Peter Hansen wrote:
> Tim Peters wrote:
> 
>> [Peter Hansen]
>>
>>> I think Skip was intending that the format string be mandatory,
>>> to avoid such ambiguity.  
>>
>>
>> It's still a bottomless pit -- ask Brett, who implemented the Python
>> strptime <wink>.  
> 
> 
> True, I did overlook timezones at the time.
> 
> On the other hand, that's because *my* use cases for "simple"
> fromstring() behaviour are all involving local time.  When
> I'm interested in non-local time, I would be happy having
> to specify that behaviour in a more complex manner.
> 
>> OTOH, is that what people really want?  For all I know,
>> rfc822.getdate() or rfc822.getdate_tz() are what's really wanted, or
>> maybe some DWIM thing like Zope's date guessers.
> 
> 
> To each his own, although I think there's a hope here that
> for those who might need/want a really simple solution,
> 95% of people have this in mind (pseudo-code):
> 
> class datetime.date:
>     def fromstring(format, string):
>         ts = time.mktime(time.strptime(string, format))
>         return datetime.date.fromtimestamp(ts)
> 

Hear, hear, the above would be great!



More information about the Python-list mailing list