def test_decoded_for_displays(self): self.assertEqual( utils.decode_for_display(datetime(year=2012, month=1, day=12)), '12.01.2012 00:00' ) self.assertEqual( utils.decode_for_display(datetime(1889, 5, 12, 12)), '12.05.1889 12:00' ) self.assertEqual( utils.decode_for_display(datetime(3, 5, 12, 13, 3)), '12.05.0003 13:03' ) self.assertEqual( utils.decode_for_display(date(2012, 1, 12)), '12.01.2012' ) self.assertEqual( utils.decode_for_display(date(1889, 5, 12)), '12.05.1889' ) self.assertEqual( utils.decode_for_display(date(3, 5, 12)), '12.05.0003' )
def display_reservation_data(self, value): """ Transforms json data values into a human readable format where appropriate. """ if isinstance(value, basestring): return self.decode_for_display(value) if isinstance(value, list): return ', '.join(self.decode_for_display(v) for v in value) if value is True: return _(u'Yes') if value is False: return _(u'No') if isinstance(value, basestring): return utils.decode_for_display(value) if isinstance(value, list): return ', '.join(utils.decode_for_display(v) for v in value) return value
def test_decoded_for_displays(self): self.assertEqual( utils.decode_for_display(datetime(year=2012, month=1, day=12)), '12.01.2012 00:00') self.assertEqual(utils.decode_for_display(datetime(1889, 5, 12, 12)), '12.05.1889 12:00') self.assertEqual(utils.decode_for_display(datetime(3, 5, 12, 13, 3)), '12.05.0003 13:03') self.assertEqual(utils.decode_for_display(date(2012, 1, 12)), '12.01.2012') self.assertEqual(utils.decode_for_display(date(1889, 5, 12)), '12.05.1889') self.assertEqual(utils.decode_for_display(date(3, 5, 12)), '12.05.0003')
def decode_for_display(self, value): value = translate(value, context=self._request, domain='seantis.reservation') return utils.decode_for_display(safe_unicode(value))