Did I find the right examples for you? yes no      Crawl my project      Python Jobs

All Samples(174)  |  Call(131)  |  Derive(0)  |  Import(43)
Return a time formatted according to the given pattern.

>>> t = time(15, 30)
>>> format_time(t, locale='en_US')
u'3:30:00 PM'
>>> format_time(t, format='short', locale='de_DE')
u'15:30'

If you don't want to use the locale default formats, you can specify a
custom time pattern:(more...)

        def format_time(time=None, format='medium', tzinfo=None, locale=LC_TIME):
    r"""Return a time formatted according to the given pattern.

    >>> t = time(15, 30)
    >>> format_time(t, locale='en_US')
    u'3:30:00 PM'
    >>> format_time(t, format='short', locale='de_DE')
    u'15:30'

    If you don't want to use the locale default formats, you can specify a
    custom time pattern:

    >>> format_time(t, "hh 'o''clock' a", locale='en')
    u"03 o'clock PM"

    For any pattern requiring the display of the time-zone a
    timezone has to be specified explicitly:

    >>> t = datetime(2007, 4, 1, 15, 30)
    >>> tzinfo = get_timezone('Europe/Paris')
    >>> t = tzinfo.localize(t)
    >>> format_time(t, format='full', tzinfo=tzinfo, locale='fr_FR')
    u'15:30:00 heure avanc\xe9e d\u2019Europe centrale'
    >>> format_time(t, "hh 'o''clock' a, zzzz", tzinfo=get_timezone('US/Eastern'),
    ...             locale='en')
    u"09 o'clock AM, Eastern Daylight Time"

    As that example shows, when this function gets passed a
    ``datetime.datetime`` value, the actual time in the formatted string is
    adjusted to the timezone specified by the `tzinfo` parameter. If the
    ``datetime`` is "naive" (i.e. it has no associated timezone information),
    it is assumed to be in UTC.

    These timezone calculations are **not** performed if the value is of type
    ``datetime.time``, as without date information there's no way to determine
    what a given time would translate to in a different timezone without
    information about whether daylight savings time is in effect or not. This
    means that time values are left as-is, and the value of the `tzinfo`
    parameter is only used to display the timezone name if needed:

    >>> t = time(15, 30)
    >>> format_time(t, format='full', tzinfo=get_timezone('Europe/Paris'),
    ...             locale='fr_FR')
    u'15:30:00 heure normale de l\u2019Europe centrale'
    >>> format_time(t, format='full', tzinfo=get_timezone('US/Eastern'),
    ...             locale='en_US')
    u'3:30:00 PM Eastern Standard Time'

    :param time: the ``time`` or ``datetime`` object; if `None`, the current
                 time in UTC is used
    :param format: one of "full", "long", "medium", or "short", or a custom
                   date/time pattern
    :param tzinfo: the time-zone to apply to the time for display
    :param locale: a `Locale` object or a locale identifier
    """
    if time is None:
        time = datetime.utcnow()
    elif isinstance(time, number_types):
        time = datetime.utcfromtimestamp(time)
    if time.tzinfo is None:
        time = time.replace(tzinfo=UTC)
    if isinstance(time, datetime):
        if tzinfo is not None:
            time = time.astimezone(tzinfo)
            if hasattr(tzinfo, 'normalize'): # pytz
                time = tzinfo.normalize(time)
        time = time.timetz()
    elif tzinfo is not None:
        time = time.replace(tzinfo=tzinfo)

    locale = Locale.parse(locale)
    if format in ('full', 'long', 'medium', 'short'):
        format = get_time_format(format, locale=locale)
    return parse_pattern(format).apply(time, locale)
        


src/w/e/webapp2_example-HEAD/lib/webapp2_extras/i18n.py   webapp2_example(Download)
            kwargs['tzinfo'] = self.tzinfo
 
        return dates.format_time(time, format, locale=self.locale, **kwargs)
 
    def format_timedelta(self, datetime_or_timedelta, granularity='second',

src/v/e/veil-HEAD/src/veil/frontend/locale/l10n.py   veil(Download)
        if is_naive_datetime(value):
            value = convert_naive_datetime_to_aware(value)
    return babel.dates.format_time(time=value, format=format, tzinfo=DEFAULT_CLIENT_TIMEZONE, locale=get_current_locale())
 
 

src/k/i/kitsune-HEAD/kitsune/sumo/helpers.py   kitsune(Download)
import jinja2
from babel import localedata
from babel.dates import format_date, format_time, format_datetime
from babel.numbers import format_decimal
from jingo import register, env
        if convert_value.toordinal() == today:
            formatted = _lazy(u'Today at %s') % format_time(
                convert_value, format='short', tzinfo=convert_tzinfo,
                locale=locale)
        else:
        formatted = format_date(convert_value, locale=locale)
    elif format == 'time':
        formatted = format_time(convert_value, tzinfo=convert_tzinfo,
                                locale=locale)
    elif format == 'datetime':

src/r/e/reddit-plugin-liveupdate-HEAD/reddit_liveupdate/utils.py   reddit-plugin-liveupdate(Download)
import pytz
 
from babel.dates import format_time, format_datetime
from pylons import c
from r2.lib import websockets
    if date == today:
        return format_time(
            time=dt,
            tzinfo=display_tz,
            format="HH:mm" + format_suffix,

src/f/j/fjord-HEAD/vendor/packages/Babel/babel/support.py   fjord(Download)
 
from babel.core import Locale
from babel.dates import format_date, format_datetime, format_time, \
     format_timedelta
from babel.numbers import format_number, format_decimal, format_currency, \
        u'11:30:00 AM'
        """
        return format_time(time, format, tzinfo=self.tzinfo, locale=self.locale)
 
    def timedelta(self, delta, granularity='second', threshold=.85,

src/z/e/ZenPacks.zenoss.OpenStack-HEAD/src/Babel-1.3/babel/support.py   ZenPacks.zenoss.OpenStack(Download)
 
from babel.core import Locale
from babel.dates import format_date, format_datetime, format_time, \
     format_timedelta
from babel.numbers import format_number, format_decimal, format_currency, \
        u'11:30:00 AM'
        """
        return format_time(time, format, tzinfo=self.tzinfo, locale=self.locale)
 
    def timedelta(self, delta, granularity='second', threshold=.85,

src/b/a/Babel-1.3/babel/support.py   Babel(Download)
 
from babel.core import Locale
from babel.dates import format_date, format_datetime, format_time, \
     format_timedelta
from babel.numbers import format_number, format_decimal, format_currency, \
        u'11:30:00 AM'
        """
        return format_time(time, format, tzinfo=self.tzinfo, locale=self.locale)
 
    def timedelta(self, delta, granularity='second', threshold=.85,

src/w/e/webapp-improved-HEAD/lib/babel/babel/support.py   webapp-improved(Download)
 
from babel.core import Locale
from babel.dates import format_date, format_datetime, format_time, \
                        format_timedelta
from babel.numbers import format_number, format_decimal, format_currency, \
        :see: `babel.dates.format_time`
        """
        return format_time(time, format, tzinfo=self.tzinfo, locale=self.locale)
 
    def timedelta(self, delta, granularity='second', threshold=.85):

src/p/l/plexnet-HEAD/third_party/python/babel/support.py   plexnet(Download)
 
from babel.core import Locale
from babel.dates import format_date, format_datetime, format_time, \
                        format_timedelta, LC_TIME
from babel.numbers import format_number, format_decimal, format_currency, \
        :see: `babel.dates.format_time`
        """
        return format_time(time, format, tzinfo=self.tzinfo, locale=self.locale)
 
    def timedelta(self, delta, granularity='second', threshold=.85):

src/b/a/babel-HEAD/babel/support.py   babel(Download)
 
from babel.core import Locale
from babel.dates import format_date, format_datetime, format_time, \
                        format_timedelta, LC_TIME
from babel.numbers import format_number, format_decimal, format_currency, \
        :see: `babel.dates.format_time`
        """
        return format_time(time, format, tzinfo=self.tzinfo, locale=self.locale)
 
    def timedelta(self, delta, granularity='second', threshold=.85):

  1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9  Next