format_date() behavior

4 views
Skip to first unread message

Eli Carter

unread,
Jun 8, 2007, 5:18:33 PM6/8/07
to trac...@googlegroups.com
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?

Eli

Jeroen Ruigrok van der Werven

unread,
Jun 8, 2007, 5:23:22 PM6/8/07
to trac...@googlegroups.com
-On [20070608 23:18], Eli Carter (eli.c...@commprove.com) wrote:
>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.

Ah, so *that* is why, when I nuke 'due date' from my milestones it keeps
getting filled in with now()?

--
Jeroen Ruigrok van der Werven <asmodai(-at-)in-nomine.org> / asmodai
イェルーン ラウフロック ヴァン デル ウェルヴェン
http://www.in-nomine.org/ | http://www.rangaku.org/
Everything comes to those who wait...

Eli Carter

unread,
Jun 8, 2007, 5:30:26 PM6/8/07
to trac...@googlegroups.com

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.

Eli

Eli Carter

unread,
Jun 8, 2007, 5:32:05 PM6/8/07
to trac...@googlegroups.com
On Friday 08 June 2007, Jeroen Ruigrok van der Werven wrote:
>
> -On [20070608 23:18], Eli Carter (eli.c...@commprove.com) wrote:
> >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.
>
> Ah, so *that* is why, when I nuke 'due date' from my milestones it keeps
> getting filled in with now()?

Yep.

I find it annoying, personally...

Eli

Jeroen Ruigrok van der Werven

unread,
Jun 8, 2007, 5:35:59 PM6/8/07
to trac...@googlegroups.com
-On [20070608 23:31], Eli Carter (eli.c...@commprove.com) wrote:
>I find it annoying, personally...

It is. And it makes no sense from a usability point of view, at least from my
perspective.

So chalk up a +1 if you want to fix it. ;)

--
Jeroen Ruigrok van der Werven <asmodai(-at-)in-nomine.org> / asmodai
イェルーン ラウフロック ヴァン デル ウェルヴェン
http://www.in-nomine.org/ | http://www.rangaku.org/

Dream, a noise, the wind awakes me, and you're already here...

Christopher Lenz

unread,
Jun 8, 2007, 5:46:32 PM6/8/07
to trac...@googlegroups.com
-------- Original-Nachricht --------
Datum: Fri, 8 Jun 2007 16:30:26 -0500
Von: Eli Carter <eli.c...@commprove.com>
An: trac...@googlegroups.com
Betreff: [Trac-dev] Re: format_date() behavior

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/

Reply all
Reply to author
Forward
0 new messages