Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion DurationField, request for help and comments

Received: by 10.210.39.8 with SMTP id m8mr41665ebm.4.1243367170280;
        Tue, 26 May 2009 12:46:10 -0700 (PDT)
Return-Path: <gulop...@gmail.com>
Received: from mail-ew0-f213.google.com (mail-ew0-f213.google.com [209.85.219.213])
        by gmr-mx.google.com with ESMTP id 15si1479388ewy.4.2009.05.26.12.46.09;
        Tue, 26 May 2009 12:46:09 -0700 (PDT)
Received-SPF: pass (google.com: domain of gulop...@gmail.com designates 209.85.219.213 as permitted sender) client-ip=209.85.219.213;
Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of gulop...@gmail.com designates 209.85.219.213 as permitted sender) smtp.mail=gulop...@gmail.com; dkim=pass (test mode) header...@gmail.com
Received: by ewy9 with SMTP id 9so4563416ewy.13
        for <django-developers@googlegroups.com>; Tue, 26 May 2009 12:46:09 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=gamma;
        h=domainkey-signature:mime-version:received:in-reply-to:references
         :from:date:message-id:subject:to:content-type
         :content-transfer-encoding;
        bh=OAIzEEGzsQw7P4/gUCizBbXhgASNCMc3qnfG2rcbF6o=;
        b=h0o6KDQn7wPgDlRcB14oNKh0zwLloi066xWU9lOyY9HtvkMqgzCKsEDi9CxwFtyzJE
         lJMIg/h2c+wELz7TO5+xk1Pxfo66W1UiJeU+5mDJVtKDbC8DsMtY+RsXR8p0Prjb5AxZ
         3WSkG8pIGOq4Iea/NftDHDUylne+gDEYlZ2Q8=
DomainKey-Signature: a=rsa-sha1; c=nofws;
        d=gmail.com; s=gamma;
        h=mime-version:in-reply-to:references:from:date:message-id:subject:to
         :content-type:content-transfer-encoding;
        b=BgP6ZKDleqrJOIhbumzGlMNy9/l6DCQ/GoZsSs5aC5jCecdofGlfQbmEle10G/Ajkc
         7CHTIfwVBzB/TyVrPecX/VwOayAJeJVQxvyH+obnwH1VHAzUdvWCpft7LmceK+9tLn8e
         DLlGk/JWoP5IONYS34pCsq3pjE1O+rD7EtfEc=
MIME-Version: 1.0
Received: by 10.210.17.2 with SMTP id 2mr665935ebq.19.1243367168282; Tue, 26 
	May 2009 12:46:08 -0700 (PDT)
In-Reply-To: <41eceb530905261116n31a44c3cx573717d6a4701e9e@mail.gmail.com>
References: <3ae7e968-8815-47a1-bb8f-90c8bad97b93@n8g2000vbb.googlegroups.com> 
	<571089b70905241812j50cdc221m13ec54bcedc698c@mail.gmail.com> 
	<41eceb530905241927j3582d115y7fd5e953c1485...@mail.gmail.com> 
	<571089b70905260944j66096d92r9ca48269b5d54...@mail.gmail.com> 
	<7e8d40920905261024n376e05a1jf6e94462913e7...@mail.gmail.com> 
	<41eceb530905261116n31a44c3cx573717d6a4701...@mail.gmail.com>
From: Marty Alchin <gulop...@gmail.com>
Date: Tue, 26 May 2009 15:45:48 -0400
Message-ID: <7e8d40920905261245y1d8fddc3obdf8a2d8344e...@mail.gmail.com>
Subject: Re: DurationField, request for help and comments
To: django-developers@googlegroups.com
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

On Tue, May 26, 2009 at 2:16 PM, Jerome Leclanche <adys...@gmail.com> wrote:
> Right now, removing months and years is a matter of removing two lines
> from the patch. I didn't want to write a patch just to get told "it's
> lacking months/years!"; I'm also in favour of dropping it and
> following Python's style; but up until now no one except yourself and
> Yuri have given feedback, I had no reason to drop it.

My only beef here is that Yuri did mention it, with reasonable
justification in the ticket, and you did acknowledge that it could be
removed, yet it remained. I can understand the tendency to support as
much as possible until someone reigns you in, but once someone does,
it's best to listen. But, I've spoken my peace and it sounds like
we're on the same page now, so we move on.

> As for the current syntax, I believe with a small syntax helper
> somewhere next to the field, this would be and feel completely
> natural. 01:30:10 is a bit meaningless if you're not working in
> seconds. One of my application uses standard milliseconds durations,
> would I have to write 01:30:10.5 to have another 500ms? Would I need
> 1-2 other fields for milli/microseconds - which would make us go back
> to the former problem ("Many input boxes is not a nice user
> experience")?

In my view, yes, 01:30:10.5 (or 01:30:10.500000 if you prefer) would
be the better approach. I will, however, freely admit that my support
for that syntax is based on nothing more than personal preference and
a vague idea of what I believe to be more common. I don't have any
research to back it up, but I don't expect any of us do in this area.
A quick search reveals that ISO 8601 is the relevant specification
here, which would leave us with something along the lines of
PT01H30M10S. In addition to being not-so-user-friendly, it seems ISO
8601 doesn't provide for anything smaller than a second, so we're back
to that same problem anyway.

> That's the way I was going until someone came up with the idea of
> parsing a timestring. Looking back, this is much more elegant, as long
> as the user knows what to do. The need for a javascript helper is
> entirely dropped since it's extremely easy to input any kind of value,
> and the user doesn't have to convert any kind of value. If the user
> wants 17 weeks, they just input "17w" instead of having to calculate
> 119 days. If they want "1500 seconds", same thing; so on.

I'll admit, my preferred approach does drop support for weeks, and if
you were to put in more than 24 hours, 60 minutes or 60 seconds, you'd
get a big, fat error message instead of the implicit calculations that
timedelta does behind the scenes. I still disagree with the notion
that the current syntax is "extremely easy to input any kind of
value," but again, neither statement is based on very much, so it's
likely impossible to say which is "better".

We're basically debating between the two representations allowed by
ISO 8601, at least in spirit. It seems an international panel of
experts couldn't decide on one over the other either, so they allow
both. Unfortunately, that's not really in keeping with Python
philosophy ("There should be one-- and preferably only one --obvious
way to do it."), so we need to pick one or the other. Whichever way we
go, it seems some of us will be Dutch, some of us won't. Such is life.

At this point, I'd say we should table the discussion on input syntax
until after 1.1 is out the door, so we can get some input from people
who have more sway in these matters. And yes, I do realize that I'm
the one who brought it up. ;)

> Also remember not everyone has javascript enabled.

I've seen this argument before, and it doesn't hold water. A
JavaScript helper is just that: a helper. It's not required to use the
field, it just makes it a bit easier for those who need a little help.
Those without JavaScript would just get text boxes without the helper,
just like the existing date and time fields.

> As for a wrapper TimeDelta class, that's up to Yuri to explain - I
> don't see the problem with it personally.

I wasn't pointing fingers at anybody in particular, I just don't see
that it adds anything beyond Python's own datetime.timedelta. Once
years and months are removed, it basically just performs unit
conversion and provides an output format in line with the new input
syntax. Python's timedelta already does the unit conversion, so that's
just duplicated effort. As for the output format, I'd rather see that
handled at the widget level anyway, so any other Python code that
deals with timedeltas doesn't get a shock when the output isn't what
Python normally provides.

-Gul