Commits

Jun Omae committed 21dd17f

Fixed the hints for date/time picker failures with `iso8601`.

Comments (0)

Files changed (2)

trac/util/datefmt.py

     tmpl = format_datetime(t, tzinfo=utc)
     ampm = format_time(t, '%p', tzinfo=utc)
     if ampm:
-        tmpl = tmpl.replace(ampm, 'a')
+        tmpl = tmpl.replace(ampm, 'a', 1)
     return tmpl.replace('1999', 'YYYY', 1).replace('99', 'YY', 1) \
                .replace('10', 'MM', 1).replace('29', 'DD', 1) \
                .replace('23', 'hh', 1).replace('11', 'hh', 1) \
                .replace('59', 'mm', 1).replace('58', 'ss', 1)
 
-def get_month_names_jquery_ui(locale):
+def get_month_names_jquery_ui(req):
     """Get the month names for the jQuery UI datepicker library"""
+    locale = req.lc_time
+    if locale == 'iso8601':
+        locale = req.locale
     if babel and locale:
         month_names = {}
         for width in ('wide', 'abbreviated'):
             'Oct', 'Nov', 'Dec'),
     }
 
-def get_day_names_jquery_ui(locale):
+def get_day_names_jquery_ui(req):
     """Get the day names for the jQuery UI datepicker library"""
-    if babel and locale:
+    locale = req.lc_time
+    if locale == 'iso8601':
+        locale = req.locale
+    if babel and locale and locale != 'iso8601':
         day_names = {}
         for width in ('wide', 'abbreviated', 'narrow'):
             names = get_day_names(width, locale=locale)
 def get_date_format_jquery_ui(locale):
     """Get the date format for the jQuery UI datepicker library."""
     if locale == 'iso8601':
-        return 'ISO_8601'
+        return 'yy-mm-dd'
     if babel and locale:
         values = {'yyyy': 'yy', 'y': 'yy', 'M': 'm', 'MM': 'mm', 'MMM': 'M',
                   'd': 'd', 'dd': 'dd'}
 def get_time_format_jquery_ui(locale):
     """Get the time format for the jQuery UI timepicker addon."""
     if locale == 'iso8601':
-        return 'ISO_8601'
+        return 'hh:mm:ss'   # XXX timepicker doesn't support 'ISO_8601'
     if babel and locale:
         values = {'h': 'h', 'hh': 'hh', 'H': 'h', 'HH': 'hh',
                   'm': 'm', 'mm': 'mm', 's': 's', 'ss': 'ss',
     tmpl = format_time(t, tzinfo=utc)
     ampm = format_time(t, '%p', tzinfo=utc)
     if ampm:
-        tmpl = tmpl.replace(ampm, 'a')
+        tmpl = tmpl.replace(ampm, 'TT', 1)
     return tmpl.replace('23', 'hh', 1).replace('11', 'hh', 1) \
                .replace('59', 'mm', 1).replace('58', 'ss', 1) \
                

trac/web/chrome.py

         add_stylesheet(req, 'common/css/jquery-ui-addons.css')
         first_day = (req.locale.first_week_day + 1) % 7 if req.locale else 1
         add_script_data(req, jquery_ui={
-            'month_names': get_month_names_jquery_ui(req.lc_time),
-            'day_names': get_day_names_jquery_ui(req.lc_time),
+            'month_names': get_month_names_jquery_ui(req),
+            'day_names': get_day_names_jquery_ui(req),
             'date_format': get_date_format_jquery_ui(req.lc_time),
             'time_format': get_time_format_jquery_ui(req.lc_time),
             'ampm': not is_24_hours(req.lc_time),