On Dec 23, 12:52 pm, "Italo Maia" <[EMAIL PROTECTED]> wrote:
How do i make my CalendarDatePicker to show non-Us dates? I saw in the
trac that someone patched it, but  i have found no doc on how to use
it. patch:http://trac.turbogears.org/turbogears/ticket/330

From memory, you need to specifiy the date format in both the Widget
and an explicit validator, as CalendarDatePicker doen't allow you to
set the format attribute via __init__, or its default validator's
format. Best way IMO is to sublcass the DatePicker, something like:

date_format = "%d/%m/%Y"   # or "%Y-%m-%d" or whatever in useful global

class ProjectDatePicker(widgets.CalenderDatePicker):
   format = date_format   # can't set this in __init__ currently!
   validator = validators.DateConverter(format=date_format)

Works with DateTime variants as well, IIRC. Really, I think you should
be able to just pass format as a parameter to __init__ for the widget
and have pass it on to it's default validator, but there maybe some
other thinking going on that I'm missing.

Also, it would be better IMO if the default format was the ISO format
rather than the US format. Its not that much work to change, but it's
caught me out before (its easy to enter the wrong date if you're not
used to the US' month first), and the ISO format is crystal clear to
all. Be nice if the default format could be automaticlly chosen by
locale, maybe?

HTH

--
wavydavy


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"TurboGears" 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/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to