mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-08 18:54:09 -04:00
When formatting ratings, do not have an unneccessary .0
This commit is contained in:
parent
867f8a4e83
commit
36da67e37b
@ -653,7 +653,7 @@ class Metadata(object):
|
||||
elif datatype == 'bool':
|
||||
res = _('Yes') if res else _('No')
|
||||
elif datatype == 'rating':
|
||||
res = res/2.0
|
||||
res = u'%.2g'%(res/2.0)
|
||||
elif datatype in ['int', 'float']:
|
||||
try:
|
||||
fmt = cmeta['display'].get('number_format', None)
|
||||
@ -693,7 +693,7 @@ class Metadata(object):
|
||||
elif datatype == 'datetime':
|
||||
res = format_date(res, fmeta['display'].get('date_format','dd MMM yyyy'))
|
||||
elif datatype == 'rating':
|
||||
res = res/2.0
|
||||
res = u'%.2g'%(res/2.0)
|
||||
elif key == 'size':
|
||||
res = human_readable(res)
|
||||
return (name, unicode(res), orig_res, fmeta)
|
||||
@ -728,7 +728,8 @@ class Metadata(object):
|
||||
if not self.is_null('languages'):
|
||||
fmt('Languages', ', '.join(self.languages))
|
||||
if self.rating is not None:
|
||||
fmt('Rating', self.rating)
|
||||
fmt('Rating', (u'%.2g'%(float(self.rating)/2.0)) if self.rating
|
||||
else u'')
|
||||
if self.timestamp is not None:
|
||||
fmt('Timestamp', isoformat(self.timestamp))
|
||||
if self.pubdate is not None:
|
||||
|
Loading…
x
Reference in New Issue
Block a user