-------- Original-Nachricht --------
Datum: Fri, 8 Jun 2007 16:30:26 -0500
Von: Eli Carter <[EMAIL PROTECTED]>
An: [email protected]
Betreff: [Trac-dev] Re: format_date() behavior

> On Friday 08 June 2007, Eli Carter wrote:
> > 
> > All,
> > 
> > Why do format_date() and format_time() return the current time if their 
> input 
> > is empty?  This is the wrong thing for them to do in a number of places:
> the 
> > milestone duedates, the version release times, and I don't know where
> else.
> > 
> > Where is that the /correct/ behavior?
> 
> I found 3 locations where that seems to be the intent:
> ./trac/admin/templates/admin_versions.html:                       
> value="${format_datetime()}" /><br />
> ./trac/versioncontrol/templates/revisionlog.txt:# ${format_datetime()}
> ./trac/web/main.py:        'time': format_datetime(),
> 
> and 58 where we're passing something in.

This behavior is basically inherited from the time.strftime() function in the 
Python standard library: if no time is provided, assume now(). I do think this 
behavior is okay. When a code path expects a datetime to be None, it probably 
should check before calling format_xxx().

And what's the alternative, really? Returning an empty string if not datetime 
is given sounds like a bad idea to me. The only other option would be to make 
the datetime a required argument.

Cheers,
Chris
--
  http://www.cmlenz.net/

-- 
Christopher Lenz
  cmlenz at gmx.de
  http://www.cmlenz.net/


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Trac 
Development" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/trac-dev?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to