Edgewall Software

Changes between Initial Version and Version 1 of Ticket #12202


Ignore:
Timestamp:
Sep 7, 2015, 4:57:41 AM (9 years ago)
Author:
Jun Omae
Comment:

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

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #12202

    • Property Owner set to Jun Omae
    • Property Status newassigned
  • Ticket #12202 – Description

    initial v1  
    22
    33`timepicker_separator` is always `' '` when iso8601 format isn't configured. However, date/time separator isn't a space character for several locales.
     4(`{0}` is time part, `{1}` is date part in `get_datetime_format()`).
    45
    56{{{#!pycon
     
    3132...   fmts.setdefault(fmt, []).append(locale_id)
    3233...
    33 >>> fmts
    34 {u'{0} {1}': ['nb'], 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} - {0}': ['el']}
    3534>>> for fmt in fmts:
    3635...   print('%r => %s' % (fmt, ' '.join(fmts[fmt])))
     
    4140u'{1} - {0}' => el
    4241}}}
    43 
    44 Proposed changes:
    45 {{{#!diff
    46 diff --git a/trac/util/datefmt.py b/trac/util/datefmt.py
    47 index 7058c0e26..cd78fc712 100644
    48 --- a/trac/util/datefmt.py
    49 +++ b/trac/util/datefmt.py
    50 @@ -401,6 +401,15 @@ def get_first_week_day_jquery_ui(req):
    51          return (locale.first_week_day + 1) % 7
    52      return 0 # Sunday
    53 
    54 +def get_timepicker_separator_jquery_ui(req):
    55 +    locale = req.lc_time
    56 +    if locale == 'iso8601':
    57 +        return 'T'
    58 +    if babel and locale:
    59 +        return get_datetime_format('medium', locale=locale) \
    60 +               .replace('{0}', '').replace('{1}', '')
    61 +    return ' '
    62 +
    63  def is_24_hours(locale):
    64      """Returns `True` for 24 hour time formats."""
    65      if locale == 'iso8601':
    66 diff --git a/trac/web/chrome.py b/trac/web/chrome.py
    67 index dd9c3b8ed..7bd875e80 100644
    68 --- a/trac/web/chrome.py
    69 +++ b/trac/web/chrome.py
    70 @@ -59,7 +59,7 @@ from trac.util.datefmt import (
    71      from_utimestamp, http_date, utc, get_date_format_jquery_ui, is_24_hours,
    72      get_time_format_jquery_ui, user_time, get_month_names_jquery_ui,
    73      get_day_names_jquery_ui, get_timezone_list_jquery_ui,
    74 -    get_first_week_day_jquery_ui)
    75 +    get_first_week_day_jquery_ui, get_timepicker_separator_jquery_ui)
    76  from trac.util.translation import _, get_available_locales
    77  from trac.web.api import IRequestHandler, ITemplateStreamFilter, HTTPNotFound
    78  from trac.web.href import Href
    79 @@ -1276,7 +1276,7 @@ class Chrome(Component):
    80              'time_format': get_time_format_jquery_ui(req.lc_time),
    81              'ampm': not is_24_hours(req.lc_time),
    82              'first_week_day': get_first_week_day_jquery_ui(req),
    83 -            'timepicker_separator': 'T' if is_iso8601 else ' ',
    84 +            'timepicker_separator': get_timepicker_separator_jquery_ui(req),
    85              'show_timezone': is_iso8601,
    86              # default timezone must be included
    87              'timezone_list': get_timezone_list_jquery_ui() \
    88 }}}