Warning: Can't synchronize with repository "(default)" (Unsupported version control system "svn": No module named svn). Look in the Trac log for more information.

Ticket #330 (closed enhancement: fixed)

Opened 13 years ago

Last modified 12 years ago

[patch] widgets.CalendarDatePicker needs multi-format support (not just USA date support)

Reported by: Stephen Thorne <stephen@…> Owned by: anonymous
Priority: high Milestone: 0.9
Component: TurboGears Version:
Severity: normal Keywords:
Cc:

Description

In many countries, formats other than mm/dd/yyyy are used, yyyy-mm-dd (aka ISO 8601) and dd/mm/yyyy are two common alternate formats.

Attached is a patch that allows the CalendarDatePicker? to be passed a kwarg for 'date format'.

Also reduces the amount of duplicated code between CalendarDatePicker? and CalendarDateTimePicker?, by causing one to inherit from the other, and modify the default date format.

Attachments

datetimeformat.patch Download (3.6 KB) - added by Stephen Thorne <stephen@…> 13 years ago.
datetime format kwarg added

Change History

Changed 13 years ago by Stephen Thorne <stephen@…>

datetime format kwarg added

comment:1 Changed 13 years ago by anonymous

here this only works when I select the date - the default date is still displayed in US format.

comment:2 Changed 13 years ago by anonymous

update on my above statement on default date - if this helps, it was because I assigned a custom validators.DateConverter?(month_style='dd.mm.yyyy').

comment:3 Changed 13 years ago by Stephen Thorne <stephen@…>

Ahh, I see I've made an error. I've modified in my patch turbogears.validators.DateTimeValidator, and ignored the formencode.validators.DateValidator.

The DateTimeValidator? is okay to use for both Dates and DateTimes?, and will return a datetime.datetime object in both instances. But maybe this is a design flaw. Possibly the CalendarDateTimePicker and CalendarDatePicker should return datetime.datetime and datetime.date objects respectively...

comment:4 Changed 13 years ago by kevin

  • Status changed from new to closed
  • Component changed from CherryPy to TurboGears
  • Resolution set to fixed
  • Milestone set to 0.9

CalendarDatePicker? should probably return a datetime.date, but this is a fine patch for now. committed at [452]

Note: See TracTickets for help on using tickets.