Edgewall Software
Modify

Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#12202 closed defect (fixed)

Mismatch datetime separator in datetime picker for several locales

Reported by: Jun Omae Owned by: Jun Omae
Priority: normal Milestone: 1.0.9
Component: i18n Version: 1.0-stable
Severity: normal Keywords: datetimepicker
Cc: Branch:
Release Notes:

Fix parsing error in datetime picker when datetime separator of the locale isn't a space character, e.g. en_US in Babel 1.3.

API Changes:
Internal Changes:

Description (last modified by Jun Omae)

Originally reported in [50289f02/rjollos.git].

timepicker_separator is always ' ' when iso8601 format isn't configured. However, date/time separator isn't a space character for several locales. ({0} is time part, {1} is date part in get_datetime_format()).

>>> import babel
>>> babel.__version__
'0.9.6'
>>> from babel.dates import get_datetime_format
>>> from trac.util.translation import get_available_locales
>>> fmts = {}
>>> for locale_id in 'ca cs da de el en_GB en_US eo es es_AR es_MX et fa fi fr gl he hu hy it ja ko nb nl pl pt pt_BR ro ru sl sv tr uk vi zh_CN zh_TW'.split():
...   fmt = get_datetime_format('medium', locale_id)
...   fmts.setdefault(fmt, []).append(locale_id)
...
>>> for fmt in sorted(fmts):
...   print('%r => %s' % (fmt, ' '.join(fmts[fmt])))
...
u'{0} {1}' => vi
u'{1} {0}' => ca cs da de el en_GB en_US eo es es_AR es_MX et fi fr gl he hu hy it ja ko nb nl pl pt pt_BR ru sl sv tr uk zh_CN zh_TW
u'{1}, {0}' => ro
u'{1}\u060c \u0633\u0627\u0639\u062a {0}' => fa
>>> import babel
>>> babel.__version__
'1.3'
>>> from babel.dates import get_datetime_format
>>> from trac.util.translation import get_available_locales
>>> fmts = {}
>>> for locale_id in 'ca cs da de el en_GB en_US eo es es_AR es_MX et fa fi fr gl he hu hy it ja ko nb nl pl pt pt_BR ro ru sl sv tr uk vi zh_CN zh_TW'.split():
...   fmt = get_datetime_format('medium', locale_id)
...   fmts.setdefault(fmt, []).append(locale_id)
...
>>> for fmt in sorted(fmts):
...   print('%r => %s' % (fmt, ' '.join(fmts[fmt])))
...
u'{0} {1}' => nb vi
u'{1} - {0}' => el
u'{1} {0}' => ca cs da de en_GB eo es es_AR es_MX et fi fr gl hu it ja ko nl pt pt_BR sl sv tr uk zh_CN zh_TW
u'{1}, {0}' => en_US he hy pl ro ru
u'{1}\u060c\u200f {0}' => fa

Attachments (0)

Change History (6)

comment:1 by Jun Omae, 5 years ago

Description: modified (diff)
Owner: set to Jun Omae
Status: newassigned

Proposed changes in [83e0d4c90/jomae.git].

comment:2 by Jun Omae, 5 years ago

Description: modified (diff)

(modified description to use all locales)

comment:3 by Ryan J Ollos, 5 years ago

The change looks good. I might have found another issue while testing, reported in #12203.

comment:4 by Ryan J Ollos, 5 years ago

This might be unrelated, but after the upgrade of timepicker in [14312:14313], with the changes for this ticket rebased on the trunk, an error is seen in the console when the separator is anything other than a whitespace (e.g. en_US):

Error parsing the date string: Extra/unparsed characters found in date: , 11:45:29 AM
date string = Sep 5, 2015, 11:45:29 AM
date format = M d, yy

I can create another ticket for the issue if it's unrelated.

Last edited 5 years ago by Ryan J Ollos (previous) (diff)

comment:5 by Jun Omae, 5 years ago

Release Notes: modified (diff)
Resolution: fixed
Status: assignedclosed

Committed in [14314] and merged to trunk in [14315].

I think no problem about that log. The datetime picker calls original $.datepicker.parseDate before $.timepicker's parseDate is called. If the text has time part, $.datepicker.parseDate raises an exception and that log is written in console.

See https://github.com/trentrichardson/jQuery-Timepicker-Addon/blob/v1.5.5/src/jquery-ui-timepicker-addon.js#L1745.

comment:6 by Ryan J Ollos, 5 years ago

Thanks for explaining that. It seems odd to me that they explicitly log the error on line 1756 rather than suppressing it in the catch.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Jun Omae.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from Jun Omae to the specified user.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.