Merge branch 'bbmaster' of ssh://git.cy55.de/home/git/cybertools into bbmaster
This commit is contained in:
commit
d49b4888cc
5 changed files with 18 additions and 3 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -4,3 +4,4 @@ ajax/dojo/*
|
||||||
*.pydevproject
|
*.pydevproject
|
||||||
*.sublime-project
|
*.sublime-project
|
||||||
*.sublime-workspace
|
*.sublime-workspace
|
||||||
|
.settings
|
||||||
|
|
|
@ -368,7 +368,7 @@ class EmailFieldInstance(FieldInstance):
|
||||||
class BooleanFieldInstance(FieldInstance):
|
class BooleanFieldInstance(FieldInstance):
|
||||||
|
|
||||||
def marshall(self, value):
|
def marshall(self, value):
|
||||||
return value
|
return bool(value)
|
||||||
|
|
||||||
def display(self, value):
|
def display(self, value):
|
||||||
#return value and _(u'Yes') or _(u'No')
|
#return value and _(u'Yes') or _(u'No')
|
||||||
|
|
11
util/date.py
11
util/date.py
|
@ -71,7 +71,6 @@ def year(d=None):
|
||||||
d = datetime.today()
|
d = datetime.today()
|
||||||
return d.year
|
return d.year
|
||||||
|
|
||||||
|
|
||||||
def toLocalTime(d):
|
def toLocalTime(d):
|
||||||
if pytz is None or not d:
|
if pytz is None or not d:
|
||||||
return d
|
return d
|
||||||
|
@ -82,3 +81,13 @@ def toLocalTime(d):
|
||||||
return d.astimezone(cet)
|
return d.astimezone(cet)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
return d
|
return d
|
||||||
|
|
||||||
|
def month(d=None):
|
||||||
|
if d is None:
|
||||||
|
d = datetime.today()
|
||||||
|
return d.month
|
||||||
|
|
||||||
|
def day(d=None):
|
||||||
|
if d is None:
|
||||||
|
d = datetime.today()
|
||||||
|
return d.day
|
||||||
|
|
|
@ -50,9 +50,12 @@ def formatDate(dt=None, type='date', variant='medium', lang='de'):
|
||||||
return fmt.format(dt or datetime.now())
|
return fmt.format(dt or datetime.now())
|
||||||
|
|
||||||
|
|
||||||
def formatNumber(num, type='decimal', lang='de', pattern=u'#,##0.00;-#,##0.00'):
|
def formatNumber(num, type='decimal', lang='de',
|
||||||
|
pattern=u'#,##0.00;-#,##0.00', precision=2):
|
||||||
loc = locales.getLocale(lang)
|
loc = locales.getLocale(lang)
|
||||||
fmt = loc.numbers.getFormatter(type)
|
fmt = loc.numbers.getFormatter(type)
|
||||||
|
if precision:
|
||||||
|
num = round(num, precision) # avoid zope.i18n formatting bug
|
||||||
return fmt.format(num, pattern=pattern)
|
return fmt.format(num, pattern=pattern)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -15,3 +15,5 @@ Basic Formatting Functions
|
||||||
|
|
||||||
>>> format.formatNumber(17.2)
|
>>> format.formatNumber(17.2)
|
||||||
u'17,20'
|
u'17,20'
|
||||||
|
>>> format.formatNumber(13399.99999997)
|
||||||
|
u'13.400,00'
|
||||||
|
|
Loading…
Add table
Reference in a new issue