def format(self, value): """Format the value""" try: new_value = self.parse(value) if not new_value: return value if self.dt_format == 'iso8601': return new_value.isoformat() else: return fields.DateTime.format(self, value) except (AttributeError, ValueError) as e: raise fields.MarshallingError(e) except arrow.parser.ParserError: return _(str(value))
def format(self, value): dvalue = Decimal(value) if not dvalue.is_normal() and dvalue != Decimal(): raise fields.MarshallingError("Invalid Fixed precision number.") return dvalue.quantize(self.precision, rounding=ROUND_HALF_EVEN)
def format(self, value): """Format the value""" try: return fields.String.format(self, '{0:07d}'.format(int(value))) except ValueError as e: raise fields.MarshallingError(e)