Hi Olivier I've worked on a DurationField implementation (ticket: http://code.djangoproject.com/ticket/2443). However I was extremely displeased with the whole DecimalField backend. With the recent addition of BigIntegerField, I am now saving durations with a bigint and mapping them to timedelta. I wanted to post an updated patch with that overhaul but never got around to do it; since you seem to need it I'll do that right now. It's the same DurationField I use on http://db.mmo-champion.com/items/?duration=3600000000 - it can store up to a few hundred thousand years in microseconds, ought to be enough for everybody, right? :)
J. Leclanche / Adys On Wed, Jan 20, 2010 at 11:14 PM, Olivier Guilyardi <m...@xung.org> wrote: > Hi everyone, > > Django TimeField is mapped to Python datetime.time. That doesn't fit my needs > since I must deal with durations, which can exceed 24h, and datetime.time > can't > do that. > > On the MySQL side, TimeField is mapped to the MySQL TIME column type, which is > correct IMO: > http://dev.mysql.com/doc/refman/5.0/en/time.html > "TIME values may range from '-838:59:59' to '838:59:59'. The hours part may be > so large because the TIME type can be used not only to represent a time of day > (which must be less than 24 hours), but also elapsed time or a time interval > between two events (which may be much greater than 24 hours, or even > negative)." > > From basic testing, SQLite also seems to get this right. I don't know about > other database backends though. > > But what about mapping to datetime.timedelta instead of datetime.time? It > seems > that it can do the job, altough it lacks strftime(), etc... but that can be > worked around. > > I understand that the datetime.time mapping is very intuitive and must stay > here > for BC. But, if I am to prepare a patch for that, how should I proceed? > > Create a new DurationField? > > Let TimeField accept an extra 'duration' or 'delta' option so that it uses > timedelta instead of time? > > (I tend to prefer this last one) > > -- > Olivier > > -- > You received this message because you are subscribed to the Google Groups > "Django developers" group. > To post to this group, send email to django-develop...@googlegroups.com. > To unsubscribe from this group, send email to > django-developers+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-developers?hl=en. > > > >
-- You received this message because you are subscribed to the Google Groups "Django developers" group. To post to this group, send email to django-develop...@googlegroups.com. To unsubscribe from this group, send email to django-developers+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-developers?hl=en.