def _initSymbols()

in hgext/pushlog/parsedatetime/parsedatetime_consts.py [0:0]


def _initSymbols(ptc):
    """
    Helper function to initialize the single character constants
    and other symbols needed.
    """
    ptc.timeSep  = [ u':' ]
    ptc.dateSep  = [ u'/' ]
    ptc.meridian = [ u'AM', u'PM' ]

    ptc.usesMeridian = True
    ptc.uses24       = False

    if pyicu and ptc.usePyICU:
        am = u''
        pm = u''
        ts = ''

        # ICU doesn't seem to provide directly the
        # date or time seperator - so we have to
        # figure it out
        o = ptc.icu_tf['short']
        s = ptc.timeFormats['short']

        ptc.usesMeridian = u'a' in s
        ptc.uses24       = u'H' in s

        # '11:45 AM' or '11:45'
        s = o.format(datetime.datetime(2003, 10, 30, 11, 45))

        # ': AM' or ':'
        s = s.replace('11', '').replace('45', '')

        if len(s) > 0:
            ts = s[0]

        if ptc.usesMeridian:
            # '23:45 AM' or '23:45'
            am = s[1:].strip()
            s  = o.format(datetime.datetime(2003, 10, 30, 23, 45))

            if ptc.uses24:
                s = s.replace('23', '')
            else:
                s = s.replace('11', '')

            # 'PM' or ''
            pm = s.replace('45', '').replace(ts, '').strip()

        ptc.timeSep  = [ ts ]
        ptc.meridian = [ am, pm ]

        o = ptc.icu_df['short']
        s = o.format(datetime.datetime(2003, 10, 30, 11, 45))
        s = s.replace('10', '').replace('30', '').replace('03', '').replace('2003', '')

        if len(s) > 0:
            ds = s[0]
        else:
            ds = '/'

        ptc.dateSep = [ ds ]
        s           = ptc.dateFormats['short']
        l           = s.lower().split(ds)
        dp_order    = []

        for s in l:
            if len(s) > 0:
                dp_order.append(s[:1])

        ptc.dp_order = dp_order
    else:
        ptc.timeSep      = ptc.locale.timeSep
        ptc.dateSep      = ptc.locale.dateSep
        ptc.meridian     = ptc.locale.meridian
        ptc.usesMeridian = ptc.locale.usesMeridian
        ptc.uses24       = ptc.locale.uses24
        ptc.dp_order     = ptc.locale.dp_order

      # build am and pm lists to contain
      # original case, lowercase and first-char
      # versions of the meridian text

    if len(ptc.meridian) > 0:
        am     = ptc.meridian[0]
        ptc.am = [ am ]

        if len(am) > 0:
            ptc.am.append(am[0])
            am = am.lower()
            ptc.am.append(am)
            ptc.am.append(am[0])
    else:
        am     = ''
        ptc.am = [ '', '' ]

    if len(ptc.meridian) > 1:
        pm     = ptc.meridian[1]
        ptc.pm = [ pm ]

        if len(pm) > 0:
            ptc.pm.append(pm[0])
            pm = pm.lower()
            ptc.pm.append(pm)
            ptc.pm.append(pm[0])
    else:
        pm     = ''
        ptc.pm = [ '', '' ]