コード例 #1
0
ファイル: fields.py プロジェクト: team126v/odoo
    def value_to_html(self, value, options):
        if not value or len(value) < 10:
            return ''
        lang = self.user_lang()
        locale = babel.Locale.parse(lang.code)

        if isinstance(value, basestring):
            value = fields.Datetime.from_string(value[:10])

        if options and 'format' in options:
            pattern = options['format']
        else:
            strftime_pattern = lang.date_format
            pattern = posix_to_ldml(strftime_pattern, locale=locale)

        return babel.dates.format_date(value, format=pattern, locale=locale)
コード例 #2
0
ファイル: fields.py プロジェクト: AbdelghaniDr/odoo
    def value_to_html(self, value, field, options=None):
        if not value or len(value) < 10:
            return ''
        lang = self.user_lang()
        locale = babel.Locale.parse(lang.code)

        if isinstance(value, basestring):
            value = fields.Datetime.from_string(value[:10])

        if options and 'format' in options:
            pattern = options['format']
        else:
            strftime_pattern = lang.date_format
            pattern = posix_to_ldml(strftime_pattern, locale=locale)

        return babel.dates.format_date(value, format=pattern, locale=locale)
コード例 #3
0
ファイル: fields.py プロジェクト: AbdelghaniDr/odoo
    def value_to_html(self, value, field, options=None):
        if not value:
            return ''
        lang = self.user_lang()
        locale = babel.Locale.parse(lang.code)

        if isinstance(value, basestring):
            value = fields.Datetime.from_string(value)

        value = fields.Datetime.context_timestamp(self, value)

        if options and 'format' in options:
            pattern = options['format']
        else:
            strftime_pattern = (u"%s %s" % (lang.date_format, lang.time_format))
            pattern = posix_to_ldml(strftime_pattern, locale=locale)

        if options and options.get('hide_seconds'):
            pattern = pattern.replace(":ss", "").replace(":s", "")

        return unicodifier(babel.dates.format_datetime(value, format=pattern, locale=locale))
コード例 #4
0
ファイル: fields.py プロジェクト: Lennon-Liang/odoo-1
    def value_to_html(self, value, field, options=None):
        if not value:
            return ''
        lang = self.user_lang()
        locale = babel.Locale.parse(lang.code)

        if isinstance(value, basestring):
            value = fields.Datetime.from_string(value)

        value = fields.Datetime.context_timestamp(self, value)

        if options and 'format' in options:
            pattern = options['format']
        else:
            strftime_pattern = (u"%s %s" % (lang.date_format, lang.time_format))
            pattern = posix_to_ldml(strftime_pattern, locale=locale)

        if options and options.get('hide_seconds'):
            pattern = pattern.replace(":ss", "").replace(":s", "")

        return unicodifier(babel.dates.format_datetime(value, format=pattern, locale=locale))