> I'm working on a brithdate/deathdate table and am having problems with
> this limitation. Realize this is a result of python's datetime
> strftime() issue but was wondering if anyone figured out a django
> workaround that wasn't a total hackfest.

Since I haven't noticed much feedback on this, I'll toss in my
experience.

For some DOB/DOD dates I've tracked in projects, I've hit a
number of such limitations:

-as you discovered, many pieces don't like years <1900 as some DB
engines fall over, the srtftime() balks at it, and other such
issues.  Fortunately, Python's datetime module seems smart enough
about handling them for a much more generous range (through
MIN_YEAR).

-sometimes I've had parts of a date but not the whole thing (I
know the day/month but not the year of a birthday, or I know the
month/year of death but not the day)

-sometimes I know a range of years/ages such as "this person was
between the ages of 25-30"

The closest I've come to a "solution" (which may not meet your
"not a total hackfest" criterion) is to have four fields for each
date, each allowed to be null/blank:  the day-of-month, the
month, the min_year and the max_year.

So for the "this person was between 25-30", I just set

  today = datetime.date.today()
  thing.min_year = today.year - max_age
  thing.max_year = today.year - min_age

I've got some convenience functions as well which calculate the
age (returning a min/max tuple), and let you know if it's a less
nebulous date.

If I were more ambitious, I would take advantage of Django's
ability to create custom field-types and make myself a
"NebulousDateField" datatype to abstract that all out and make it
easier to reuse.

-tim

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

Reply via email to