1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- #coding=utf-8
- class Formater():
- @staticmethod
- def formatStr(value):
- res = u''
- if value != None:
- try:
- res = str(value)
- except:
- pass
- return res
- @staticmethod
- def formatCount(value):
- return int(round(float(value or 0) * 100,0))
- @staticmethod
- def formatPrice(value):
- return int(round(float(value or 0) * 100,0))
- @staticmethod
- def formatCountShow(value):
- return '%.2f' % (float(value or 0)/100.0)
- @staticmethod
- def formatPriceShow(value):
- return '%.2f' % (float(value or 0)/100.0)
- @staticmethod
- def formatAmount(value):
- return int(round(float(value or 0) * 10000,0))
- @staticmethod
- def formatAmountShow(value):
- return '%.2f' % (float(value or 0) / 10000.0 + 0.0000001)
- def clean_datetime_range(data, fieldname):
- if data is not None and fieldname in data and data[fieldname] != '':
- if data is not None:
- t = data[fieldname].split(' - ')
- # t = data[fieldname]
- data = data.copy()
- data[fieldname + '_0'] = t[0]+ ' 00:00:00'
- data[fieldname + '_1'] = t[1] + ' 23:59:59'
- else:
- t = data[fieldname].split(' - ')
- data = data.copy()
- data[fieldname+'_0'] = t[0]
- data[fieldname+'_1'] = t[1] + ' 23:59:59'
- data.pop(fieldname)
- return data
|